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?
Try just:
UNIX_TIMESTAMP()
And see here: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp