Support #4888
closedGetting current-dateTime()/js:Date() in UI/browser
0%
Description
I have a UI in which I would like to display some duration info along side certain dates. E.g. "Today at 4:00 pm (2 minutes ago)". Implementing this in xslt is easy enough, however the UI should really update this text as time marches on. If your browser stays open, at some point it should say "Yesterday at 4:00 pm (9 hours ago)".
The problem is that current-dateTime()
always returns the time at which the window was loaded. I assume this is a 'no side-effects' thing. I've tried implementing a JavaScript function that returns Date().toISOString(). That works when the pages is loaded, but when the function is called a second time I'm getting "XError:ixsl:call: property 'isoDate' is not a function; code:SXJS0007"
This is pretty common thing to do in a UI, so I assume there's a way to do it with Saxon-JS that I haven't figured out. Any guidance would be appreciated!
Updated by John Lumley about 3 years ago
Assuming you are using SaxonJS2 then you can use saxon:timestamp() which gives the current time at the point of evaluation -
https://www.saxonica.com/documentation/index.html#!functions/saxon/timestamp
Sent from my iPad
On 1 Feb 2021, at 23:05, Saxonica Developer Community notifications@plan.io wrote:
Updated by Norm Tovey-Walsh about 3 years ago
- Status changed from New to Resolved
Updated by Debbie Lockett about 3 years ago
- Status changed from Resolved to Closed
Please register to edit this issue
Also available in: Atom PDF Tracking page