简体   繁体   中英

Mysql: Inserting Current TimeStamp with microseconds Precision

As given here, We can insert fractional Seconds: http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

If Execute this Query CREATE TABLE t1 (t TIME(3), dt DATETIME(6)); and Insert using NOW() I GET 2015-09-18 20:11:40.000000 in database.

Further if I set Attribute with DATETIME ON UPDATE CURRENT_TIMESTAMP it does not store the fractional Seconds.

How can i save Fractional Seconds in MYSQL? i don't want to insert it i want the Current TimeStamp or something like NOW()? What Query can be used to Insert the Timestamp?

Further can php be used if there is no function available in MYSQL?

Have a try with the sysdate() function instead of NOW() :

SELECT sysdate(6);

Reason simply is that NOW() is based on a TIMESTAMP which only resolves to seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM