Skip to main content

Setting the Time Zone

Setting the Time Zone

You can use $ZTIMEZONE to set the time zone used by the current InterSystems IRIS process. Setting $ZTIMEZONE does not change the default InterSystems IRIS time zone or your computer’s time zone setting.

Note:

Changing the $ZTIMEZONE special variable is a feature designed for some special situations. Changing $ZTIMEZONE is not a consistent way to change the time zone that InterSystems IRIS uses for local date/time operations. The $ZTIMEZONE special variable should not be changed except by those programs that are prepared to handle all the inconsistencies that result.

On some platforms there may be a better way to change time zones than changing the $ZTIMEZONE special variable. If the platform has a process-specific time zone setting (for example, the TZ environment variable on POSIX systems) then making an external system call to change the process-specific time zone may work better than changing $ZTIMEZONE. Changing the process-specific time zone at the operating system level will change both the local time offset from UTC and apply the corresponding algorithm that determines when local time variants are applied. This is especially important if the default system time zone is in the Northern Hemisphere, while the desired process time zone is in the Southern Hemisphere. Changing $ZTIMEZONE changes the local time to a new time zone offset from UTC, but the algorithm that determines when local time variants are applied remains unchanged.

Use the SET command to set $ZTIMEZONE to a specified signed integer number of minutes. Leading zeros and decimal portions of numbers are ignored. If you specify a nonnumeric value or no value when setting $ZTIMEZONE, InterSystems IRIS sets $ZTIMEZONE to 0 (Greenwich meridian).

For example, North American Eastern Standard Time (EST) is five hours west of Greenwich. Therefore, to set the current InterSystems IRIS process to EST you would specify 300 minutes. To specify a time zone one hour east of Greenwich, you would specify –60 minutes. To specify Greenwich itself, you would specify 0 minutes.

Setting $ZTIMEZONE:

  • affects the argumentless $NOW() local time value. It changes the time portion of $NOW(), and this change of time can also change the date portion of $NOW() for the current process. $NOW() reflects the $ZTIMEZONE setting exactly, its value is not adjusted for local time variants.

  • affects the $HOROLOG local time value. $HOROLOG takes its time zone value from $ZTIMEZONE, then seasonally adjusts for local time variants such as Daylight Saving Time. $HOROLOG therefore always conforms to local clock time, but $HOROLOG elapsed time is not continuous throughout the year.

  • affects the %SYSTEM.UtilOpens in a new tab class methods IsDST()Opens in a new tab, UTCtoLocalWithZTIMEZONE()Opens in a new tab, and LocalWithZTIMEZONEtoUTC()Opens in a new tab.

  • does not affect $ZTIMESTAMP or $ZHOROLOG values.

  • does not affect the date and time format conversions performed by $ZDATE, $ZDATEH, $ZDATETIME, $ZDATETIMEH, $ZTIME, and $ZTIMEH functions.

  • does not affect the $NOW(n) function.

  • does not affect the FixedDate()Opens in a new tab class method of the %SYSTEM.ProcessOpens in a new tab class, which sets the date in $HOROLOG to a fixed value.

The following anomalies occur after changing $ZTIMEZONE:

  • $ZDATETIME($HOROLOG,1,7) usually returns an UTC time, but it will not return UTC time if $ZTIMEZONE has changed.

  • $ZDATETIME($HOROLOG,1,5) will not return the correct time zone offset if $ZTIMEZONE has changed.

  • $ZDATETIME($HOROLOG,-3) and $ZDATETIMEH($ZTIMESTAMP,-3) conversions between Local time and UTC time will not be correct if $ZTIMEZONE has changed.

FeedbackOpens in a new tab