Generating useful current-dateTime() values
July 31, 2013 Leave a comment
One common operation that you find yourself doing as a developer is time-stamping various operations. Creation DateTime, Save DateTime or Submission DateTime values are very useful when processing data. However, in Livecycle there are some small gotchas when dealing with system generated dateTime strings that they don’t make you aware of.
current-dateTime() default Timezone
Even in the latest help file for current-dateTime() XPath function, they don’t tell you that when you make a call to this function, it will always return the time string as GMT+0 no matter what timezone the server is running in. Now this is fine if you live in London, Burkina Faso or Tórshavn but no good if you live anywhere else in the world.
Adjusting the default
Adjusting this value to your default timezone is fairly easy as the format-dateTime() function does this for you if you feed it right. You just need to know what values to put in for the four optional fields and how to source them. Adobe give some help to the values on the Date and Time parameters help page and I will demonstrate using format-dateTime():
format-dateTime(strDateTime, (language, country, variant, timezone)?)
- strDateTime – currentDateTime() function
- language – Is the 2-digit ISO 639-1 code from this table
- country – Is the 2-digit ISO 3166-1 alpha-2 code from this table
- variant – Is a vendor or web browser code. Can be “WIN” or “MAC” or an underscore-delimited combination of both
- timezone – Is the TZ string from this table
So, to get the real current-dateTime() string for an application based in Auckland, New Zealand you would do the following:
format-dateTime(current-dateTime(), "en", "NZ", "WIN", "Pacific/Auckland")