XQuery current-time()
In XQuery, the fn:current-time()
function is used to retrieve the current time as a xs:time
value. This function does not take any arguments and returns the current time in the local time zone of the system on which the XQuery is executed.
The xs:time
data type represents a time value without a date component in the format “hh:mm:ss.sss”, where “hh” is the hour (00 to 23), “mm” is the minute (00 to 59), “ss” is the second (00 to 59), and “sss” is the fractional seconds.
Here’s an example of using fn:current-time()
in XQuery:
let $currentTime := fn:current-time()
return $currentTime
Output:
13:45:21.345
In this example, the variable $currentTime
is assigned the current time when the XQuery is executed. The output will display the current time in the “hh:mm:ss.sss” format.
Please note that the value returned by fn:current-time()
can vary depending on the system’s clock and time zone settings. If you need to obtain the current date and time together, you can use the fn:current-dateTime()
function, which includes both the date and time components in the xs:dateTime
format.