Tutorial by Examples

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.) ROUND(UNIX_TIMEST...
CREATE TABLE times ( dt DATETIME(3), ts TIMESTAMP(3) ); makes a table with millisecond-precision date / time fields. INSERT INTO times VALUES (NOW(3), NOW(3)); inserts a row containing NOW() values with millisecond precision into the table. INSERT INTO times VALUES ('2015-01...
%f is the fractional precision format specifier for the DATE_FORMAT() function. SELECT DATE_FORMAT(NOW(3), '%Y-%m-%d %H:%i:%s.%f') displays a value like 2016-11-19 09:52:53.248000 with fractional microseconds. Because we used NOW(3), the final three digits in the fraction are 0.
If you have a Javascript timestamp value, for example 1478960868932, you can convert that to a MySQL fractional time value like this: FROM_UNIXTIME(1478960868932 * 0.001) It's simple to use that kind of expression to store your Javascript timestamp into a MySQL table. Do this: INSERT INTO table...

Page 1 of 1