开发者

MySQL: how to get an actual TimeStamp? literally the amount of seconds since 1970-01-01 UTC

开发者 https://www.devze.com 2023-01-25 00:51 出处:网络
A MySQL timestamp field is written a开发者_开发知识库nd read as \'yyyy-MM-dd hh:mm:ss\', how can I get the actual amount of seconds since 1970-01-01 UTC?Use UNIX_TIMESTAMP.

A MySQL timestamp field is written a开发者_开发知识库nd read as 'yyyy-MM-dd hh:mm:ss', how can I get the actual amount of seconds since 1970-01-01 UTC?


Use UNIX_TIMESTAMP.

If called with no argument, 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. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD.


SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19');

or

SELECT UNIX_TIMESTAMP(fieldGoesHere) FROM blah WHERE foo = 1;
0

精彩评论

暂无评论...
验证码 换一张
取 消