Skip to content

sqlTimestamp

Corey Avis edited this page Sep 23, 2026 · 2 revisions

sqlTimestamp

Generates a SQL timestamp from the provided date/time; otherwise, defaults to now.

Usage

sqlTimestamp(string|integer|null $datetime): string

Parameters

datetime (string|integer|null) : A date/time string or Unix timestamp. (default: null) ^(optional)^

Return Value

(string) : Returns the SQL timestamp for a given date/time, or current time if datetime is null.

Examples

$fx->sqlTimestamp() = YYYY-MM-DD HH:MM:SS (current date and time)
$fx->sqlTimestamp('July 29, 2015 3:45pm') = 2015-07-29 15:45:00
$fx->sqlTimestamp(1438209900) = 2015-07-29 15:45:00
$fx->sqlTimestamp('-1 week') = YYYY-MM-DD HH:MM:SS (1 week ago)

Debug Errors

  • No debug errors.

Related Methods

emailTimestamp | isSqlTimestamp | sqlDate | sqlTime | timestamp


Home | CoreyFX | Date and Time Processing

Clone this wiki locally