How to save DATETIME or TIMESTAMP in MySQL with milliseconds precision

mysql

#1

How to save DATETIME in MySQL with milliseconds precision some thing like 2017-09-15 16:43:17.086654 instead of 2017-09-15 16:43:17.000000


#2

You need to be at MySQL version 5.6.4 or later to declare columns with fractional-second time datatypes

SELECT NOW(3)
DATETIME(3) will give you millisecond resolution in your timestamps
SELECT NOW(6)
TIMESTAMP(6) will give you microsecond resolution on a *nix-style timestamp.

Read this: http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html