Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've been trying to use the following in mySQL to create a unix stamp for current UTC time

UNIX_TIMESTAMP(UTC_TIMESTAMP())

When I execute the query and get the result, it seems like mySQL is doing UTC conversation twice.

Eg. local time 9:07PM

Query above returned: 1374390482, which is next day 07:08:02 GMT, which is correct,

However, UNIX_TIMESTAMP(LOCALTIMESTAMP()) returns:

1374372551 02:09:11 GMT

which is the correct UTC unix timestamp.

So UNIX_TIMESTAMP automatically translates the date object's timezone to UTC (regardless if it's already UTC or not?)

Is there a better way or a single command just to get a UTC unix timestamp in mySQL?

question from:https://stackoverflow.com/questions/17768426/best-way-to-get-unix-timestamp-for-current-utc-time-in-mysql

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
422 views
Welcome To Ask or Share your Answers For Others

1 Answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...