Click to See Complete Forum and Search --> : UTC_TIMESTAMP problem


auxone
03-15-2009, 11:42 PM
I have a mySQL table with a field set to "on update CURRENT_TIMESTAMP", all I want is to change that to UTC_TIMESTAMP.

The following code is giving me a generic error:
ALTER TABLE `stamp_table` CHANGE `stamp` `stamp` DATETIME ON UPDATE UTC_TIMESTAMP NOT NULL DEFAULT UTC_TIMESTAMP

Anyone know why? I've tried to several different ways.

thanks in advance.

Phill Pafford
03-16-2009, 10:22 AM
Are you in UTC timezone?


Quote from MySQL (http://dev.mysql.com/doc/refman/5.0/en/timestamp.html)
CURRENT_TIMESTAMP or any of its synonyms (CURRENT_TIMESTAMP(), NOW(), LOCALTIME, LOCALTIME(), LOCALTIMESTAMP, or LOCALTIMESTAMP()) can be used in the DEFAULT and ON UPDATE clauses. They all mean “the current timestamp.” (UTC_TIMESTAMP is not allowed. Its range of values does not align with those of the TIMESTAMP column anyway unless the current time zone is UTC.)


Could you just convert the timestamp to UTC (http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_utc-timestamp)in your code instead of the DB?

auxone
03-16-2009, 10:55 AM
Hmm. I didn't come across that statement in my search. Thanks for the info.

I am not UTC local, but I just wanted a way to make sure my timestamps were universal and not dependent on the timezone of the server my database is currently on, nor affected by daylight saving time. The table in question is accessed via several scripts, perhaps a dozen or so, I was hoping to avoid tracking them all down by getting the on update clause working since it's exactly what I need. Alas.

Thanks again.