How to change the special variable $ZTIMESTAMP to your local time zone
InterSystems FAQ rubric
$ZTIMESTAMP returns the date and time in UTC format, so to change it to the local time zone, use the following system method:
$SYSTEM.Util.UTCtoLocalWithZTIMEZONE($ZTIMESTAMP)The above output will be in the format ddddd,sssss.fff.
ddddd: Same format as $HOROLOG dates
sssss: An integer indicating the number of seconds elapsed since midnight on the current date
fff: Variable number of digits indicating the fractional part of a second
* Similar to $HOROLOG, except that $HOROLOG does not include fractional seconds.
SAMPLES>write$SYSTEM.Util.UTCtoLocalWithZTIMEZONE($ZTIMESTAMP)," - ", $horolog,!
63895,64252.66 - 63895,64252
SAMPLES>write$ZDATETIME($SYSTEM.Util.UTCtoLocalWithZTIMEZONE($ZTIMESTAMP),8)
2015120917:45:56
SAMPLES>write$ZDATETIME($ZTIMESTAMP,8)
2015120908:46:05
SAMPLES>Discussion (0)0
Comments
Manipulating time values is a risky ground. See this simple example.
USER>write ?1%, $ZTZ," : ",$zdt($ZTS)," : ",$zdt($now())," : ",$zdt($h)
-60 : 07/04/202416:03:42 : 07/04/202417:03:42 : 07/04/202418:03:42- $ZTZ is the geographic offset to UTC in minutes
- $ZTS is UTC time (no daylight saving !)
- $NOW() is UTC adjusted by $ZTZ (no daylight saving or special time zone adjustment)
- $H is based on the time set in your server OS
So for international applications using anything else than UTC is an open trap you might be caught in.
This was the original motivation to use UTC in ENSEMBLE and it's descendants and followers