Def normalize(dt, tz=UTC): ' Convert date or datetime to datetime with timezone.
If I am moving databases between servers datetime/timestamp fields with different timezones; I have been doing:
Description Conveniently get and set the time zone of a date-time. TIMESTAMPTZ currently only stores the offset of a given time zone, not the actual time zone, at the moment of creation for a given value.This is especially important to note when dealing with daylight saving time, which is not utilized by UTC. Great, thanks Hugo! If it passes both R CMD check actel.tar.gz and TZ=UTC R CMD check actel.tar.gz then yes it's solved. Alternatively, and probably better and easier (and what we do in data.table tests) is you can also use Sys.setenv(TZ='UTC') in your tests and fread will read that latest value set in the R session. This avoids needing to run R CMD check twice, with and without TZ=UTC.
then reloading it on the server with different timezone. This appears to work and the dates are correct.
It seems that according to sql manual I shouldn't have to do this:
This option enables
TIMESTAMP columns to be dumped and reloaded between servers in different time zones.
mysqldump sets its connection time zone to UTC and adds
SET TIME_ZONE='+00:00' to the dump file. Without this option,
TIMESTAMP columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones.
--tz-utc also protects against changes due to daylight saving time.
--tz-utc is enabled by default. To disable it, use
I guess I don't understand exactly how this works.
What is the proper way to move data between servers that have different timezones?
EDIT to show that –tz-utc=false is a real statement
Coordinated universal time zone map. Prior to 1972, this time was called Greenwich Mean Time (GMT) but is now referred to as Coordinated Universal Time or Universal Time Coordinated (UTC). It is a coordinated time scale, maintained by the Bureau International des Poids et Mesures (BIPM). It is also known as 'Z time' or 'Zulu Time'. Coordinated Universal Time (UTC) +0000 UTC UTC/GMT is 01:13 on Monday, May 3, 2021. Universal Time is a solar time standard that reflects the average speed of the Earth's rotation. Using the prime meridian at 0° longitude as a reference point, it shows the actual length of an average solar day on Earth, which is the time from one solar noon to the next. UTC (GMT/Zulu)-time: Monday, May 3, 2021 at 06:54:47. UTC is Coordinated Universal Time, GMT is Greenwich Mean Time. Great Britain/United Kingdom is one hour ahead of UTC during summer. Universal Time (UT) was created at the International Meridian Conference in 1884. This is the basis for the 24-hour time zone system we know today. At the time, Greenwich Mean Time (GMT) was chosen as the world’s time standard.