Skip to main content
100%

Milliseconds since Unix Epoch

✓ Published0🌍 Public
CCliffordAnderson
Last edited Aug 29, 2016
Created on Aug 29, 2016

This example converts the current date and time into a single integer representing the number of milliseconds elapsed since the Unix epoch (January 1, 1970). It uses the XQuery function `local:milliseconds-since-epoch`, which calculates the duration between the current timestamp and the epoch, then extracts and sums the day, hour, minute, and second components scaled to milliseconds. The code relies on XQuery’s built-in date and duration types and functions, including `fn:current-dateTime()`, `xs:dateTime()`, `xs:duration()`, and `fn:days-from-duration()`. The result is returned as an `xs:integer`, demonstrating a fundamental time-conversion utility.

AI-generated description

Similar vizzes