Get the current time in a form that looks like a Javascript timestamp.

suggest change

Javascript timestamps are based on the venerable UNIX time_t data type, and show the number of milliseconds since 1970-01-01 00:00:00 UTC.

This expression gets the current time as a Javascript timestamp integer. (It does so correctly regardless of the current time_zone setting.)

SELECT ROUND(UNIX_TIMESTAMP(NOW(3)) * 1000.0, 0);

UNIX_TIMESTAMP() on a TIMESTAMP column returns seconds since 1970-01-01 00:00:00 UTC, independent of the session time zone:

SELECT ROUND(UNIX_TIMESTAMP(column) * 1000.0, 0);

On a DATETIME column, UNIX_TIMESTAMP() treats the value as a wall clock in the session time zone. DATETIME does not store a time zone, so the resulting epoch time shifts if time_zone changes.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents