current-dateTime() returns local or UTC time?
Added by Anonymous about 19 years ago
Legacy ID: #3440357 Legacy Poster: Spenser (spenserkao)
A test of XPath 2.0 function current-dateTime() I have done at local time 14:17:22 23 Nov 2005 AEDT (zone name: Australia/Melbourne) returned me the raw output 2005-11-23T14:17:22.475+11:00. The output's last part (+11:00) tells me that it inteded to be in UTC (Coordinated Universial Time) format, but the leading dateTime remains as local time, which raised me a question: Shouldn't the correct output in this case be 2005-11-23T03:17:22.475+11:00? Regards, Spenser
Replies (5)
Please register to reply
RE: current-dateTime() returns local or UTC t - Added by Anonymous about 19 years ago
Legacy ID: #3440359 Legacy Poster: Spenser (spenserkao)
I like to add that the tests performed with both Saxon7.8 and Saxon8 under WinXP environment prodcued the same result. Spenser
RE: current-dateTime() returns local or UTC t - Added by Anonymous about 19 years ago
Legacy ID: #3440860 Legacy Poster: Michael Kay (mhkay)
The ISO 8601 date/time format consists of the local time followed by a timezone indication, not a UTC time followed by a timezone indication. Confusing perhaps, but that's the way it is. Michael Kay
RE: current-dateTime() returns local or UTC t - Added by Anonymous about 19 years ago
Legacy ID: #3441198 Legacy Poster: Kevin Rodgers (notorious_kev)
This is what I use to get UTC; is it correct? <xsl:variable name="now" select="current-dateTime()"/> <xsl:variable name="GMT" select="xdt:dayTimeDuration('PT0H')"/> <xsl:value-of select="adjust-dateTime-to-timezone($now, $GMT)"/> Thanks, -- Kevin
RE: current-dateTime() returns local or UTC t - Added by Anonymous about 19 years ago
Legacy ID: #3442040 Legacy Poster: Spenser (spenserkao)
Hi Kevin, No wrong with the way you got UTC, the output from adjust-dateTime-to-timezon() is virtually the concatenation of that of current-dateTime(), such as 2005-11-23T14:17:22.475, and that of dayTimeDuration(), such as +11:00, which comes out 2005-11-23T14:17:22.475+11:00. Thanks to Michael for his correction on my interpretation of ISO 8601. Cheers, Spenser
RE: current-dateTime() returns local or UTC t - Added by Anonymous about 19 years ago
Legacy ID: #3442066 Legacy Poster: Michael Kay (mhkay)
<xsl:variable name="now" select="current-dateTime()"/> <xsl:variable name="GMT" select="xdt:dayTimeDuration('PT0H')"/> <xsl:value-of select="adjust-dateTime-to-timezone($now, $GMT)"/> Looks OK to me. By the way, there's nothing Saxon-specific on this thread. Discussion of XSLT/XPath coding that's product-independent would be better conducted on the xsl-list at mulberrytech.com Michael Kay
Please register to reply