Question
· May 24, 2016

Storing events with current date/time using UTC ($ZTimeStamp) instead of $Horolog - Best practices discussion

Hi everyone!

     I am helping a partner to develop a new application and one of the things we are facing is that this WEB application will be used on different time zones.

     My first recommendation is that all timestamps should be drawn from $ZTimeStamp instead of $Horolog. That would allow the system to be draw the correct sequence of events even when they are generated on different timezones. 

     On the other hand, it is sometimes useful to know what was the local timezone at the moment the event was generated to compare to events generated on other systems or to correlate to people's recollection of facts (people deal with $Horolog concept of time).

     So, to cope with these requirements, besides storing the date/time as a %TimeStamp drawn from $ZTimeStamp, I would also store the local timezone of the user that generated the event or maybe simply also store the date/time drawn from $Horolog together with the date/time drawn from $ZTimeStamp. Always store two timestamps, one for local date/time and another for UTC date/time looks like a nice solution.

     I would like to know about other people's experience about this, pitfalls, tips, anything.

Kind regards,

Amir Samary

Discussion (1)0
Log in or sign up to continue

Save timestamp with user timezone (get timezone from request), for example (returns server timezone):

write $ZDATETIME($HOROLOG, 1, 5)

Return timestamp to a client, there are a lot of js libraries which automatically convert incoming timestamp with a different timezone into user's local time.

The advantage of this approach is that you only need to convert timezone once, the rest would be done on client.

Check out ISO 8601  for timestamp formats with timezone support and which js understands.

This approach works best, when you don't need to access your application data from the systems without support for this type of timestamp.