Hi all I want to print the current date and time on a HTML page using XQuery's format-dateTime function. The problem is that I always get the GMT time which currently is 2 hours behind of Central Europe Time. This is what my code looks like: <p>Stand vom {format-dateTime(current-dateTime(), '[D01].[M01].[Y0001] [H01]:[m01]:[s01]', 'de')} Uhr</p> And this is what I get when local time is 15:21:34: Stand vom 27.04.2016 13:21:34 Uhr Is it possible to get the local time using format-dateTime? Thanks for any help! Mike
Hi Mike,
Stand vom 27.04.2016 13:21:34 Uhr
That’s interesting; the same query here in Konstanz/Germany gives me: <p>Stand vom 27.04.2016 15:38:53 Uhr</p> Maybe this is due to your server settings? You can enforce the time adjustment as follows: adjust-dateTime-to-timezone( current-dateTime(), xs:dayTimeDuration('PT2H') ) It is true that the XQuery 3.1 F&O spec allows you to specify a place [1]. This hasn’t been implemented yet… Hope this helps, Christian [1] https://www.w3.org/TR/xpath-functions-31/#rules-for-datetime-formatting
Hi Christian You were right: as I'm running BaseX on a VM I checked the time on the VM's server and this is the time I get when runing the XQuery.Your workaround solution with the adjust-dateTime-to-timezone function also worked as expected. Thnx! Best regardsMike From: Christian Grün <christian.gruen@gmail.com> To: Mike Cobo <mikecobo@yahoo.com> Cc: "basex-talk@mailman.uni-konstanz.de" <basex-talk@mailman.uni-konstanz.de> Sent: Wednesday, April 27, 2016 3:43 PM Subject: Re: [basex-talk] Print local time Hi Mike,
Stand vom 27.04.2016 13:21:34 Uhr
That’s interesting; the same query here in Konstanz/Germany gives me: <p>Stand vom 27.04.2016 15:38:53 Uhr</p> Maybe this is due to your server settings? You can enforce the time adjustment as follows: adjust-dateTime-to-timezone( current-dateTime(), xs:dayTimeDuration('PT2H') ) It is true that the XQuery 3.1 F&O spec allows you to specify a place [1]. This hasn’t been implemented yet… Hope this helps, Christian [1] https://www.w3.org/TR/xpath-functions-31/#rules-for-datetime-formatting
participants (2)
-
Christian Grün -
Mike Cobo