简体   繁体   中英

MySQL: how do you convert a datetime to unix time?

我可以这样做是一个查询吗?

请参阅UNIX_TIMESTAMP()函数。

This can be done in MySQL by using UNIX_TIMESTAMP() or UNIX_TIMESTAMP(date).

If called with no argument, this returns a Unix timestamp (seconds since '1970-01-01 00:00:00' UTC) as an unsigned integer.

If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC.

mysql> SELECT UNIX_TIMESTAMP();
        -> 1196440210
mysql> SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19');
        -> 1196440219

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