![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
* * *TIMESTAMP fields are stored in UTC, but a SELECT returns them adjusted to the server's time zone. *How can I get the timestamp in UTC, without conversion? * * *UTC_TIMESTAMP() returns the current timestamp only; it doesn't take an argument. *So that's no help. * * *CONVERT_TZ(timeval,'SYSTEM','+0:00') turns out to work. *A more correct form is * * *CONVERT_TZ(timeval, @@time_zone, '+0:00') which should compensate for any server-side time zone. * * *This is clunky, though. *Is there some way to just retrieve the timestamp in UTC? * * * * * * * * * * * * * * * * John Nagle |
#3
| |||
| |||
|
|
TIMESTAMP fields are stored in UTC, but a SELECT returns them adjusted to the server's time zone. |
|
How can I get the timestamp in UTC, without conversion? |
|
CONVERT_TZ(timeval, @@time_zone, '+0:00') This is clunky, though. Is there some way to just retrieve the timestamp in UTC? |
#4
| |||
| |||
|
|
John Nagle<nagle (AT) animats (DOT) com> wrote: TIMESTAMP fields are stored in UTC, but a SELECT returns them adjusted to the server's time zone. s/server/current connection/ How can I get the timestamp in UTC, without conversion? By asking to get it in UTC? I.e. like so: CONVERT_TZ(timeval, @@time_zone, '+0:00') This is clunky, though. Is there some way to just retrieve the timestamp in UTC? What is the problem with the above? Maybe you rather want to set the time zone for that connection to UTC? |
|
-- near the start of the dump file /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; -- now there is data, including timestamps in UTC -- near the end of the dump file /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; |
#5
| |||
| |||
|
|
On 11/29/2010 3:00 AM, Axel Schwenke wrote: CONVERT_TZ(timeval, @@time_zone, '+0:00') This is clunky, though. Is there some way to just retrieve the timestamp in UTC? What is the problem with the above? For one hour each year in areas that use daylight savings time, local time is ambiguous. |
|
It seems weird that there isn't some straightforward way to retrieve TIMESTAMP values in UTC, regardless of time zone settings. |
#6
| |||
| |||
|
|
John Nagle <nagle (AT) animats (DOT) com> wrote: It seems weird that there isn't some straightforward way to retrieve TIMESTAMP values in UTC, regardless of time zone settings. |
![]() |
| Thread Tools | |
| Display Modes | |
| |