xml
  1. xml-current-datetime

XML current-dateTime()

The current-dateTime() function is an XQuery time and date function that returns the current date and time in the xs:dateTime format.

Syntax

The syntax for the current-dateTime() function is as follows:

current-dateTime() => xs:dateTime

Example

let $dateTime := current-dateTime()
return $dateTime

Output

2022-01-25T01:23:56.585Z

Explanation

The current-dateTime() function returns the current date and time in the xs:dateTime format, which includes the date and time components. The date is represented in the format of yyyy-mm-dd and the time is represented in the format of hh:mm:ss.sss.

Use

The current-dateTime() function is typically used to capture and record the current date and time of a particular event, such as when an XML document was created or modified.

Important Points

  • The current-dateTime() function is a built-in function and requires no imports or external libraries.
  • The xs:dateTime format adheres to the ISO 8601 standard for date and time representation.
  • The current-dateTime() function always returns the current date and time based on the server's clock.

Summary

The current-dateTime() function is an XQuery time and date function that returns the current date and time in the xs:dateTime format. It is used to capture and record the current date and time of a particular event. The format adheres to the ISO 8601 standard and always returns the current date and time based on the server's clock.

Published on: