saxon:timestamp

Returns an xs:dateTimeStamp value representing the instant in time at which the function is called.

timestamp() ➔ xs:dateTimeStamp

There are no arguments

Result

xs:dateTimeStamp

Namespace

http://saxon.sf.net/

Notes on the Saxon implementation

Available since Saxon 9.8.

Details

The function returns an xs:dateTimeStamp value representing (as far as possible) the instant at which the function is called. This differs from fn:current-dateTime() in that successive calls return different values. This enables the result to be used for performance instrumentation.

The precision of the result depends on the platform. The xs:dateTime implementation is capable of representing microsecond precision. On JDK 8, Saxon calls the java.time.Instant class, which is capable of representing nanosecond precision, but some platforms only return millisecond precision. When used with an earlier JDK, Saxon gets the date and time from the GregorianCalendar class, and the result typically has millisecond precision.

The timezone in the result is the implicit timezone from the dynamic context (which in turn is taken from the system clock).

Saxon attempts to avoid aggressive optimization of calls to this function, so for example a call will not be lifted out of a loop. However, order of execution is not guaranteed, so there may still be surprises. If the result is bound to a variable, for example, the variable may be lazily evaluated, which means the timestamp will show the time at which the variable is evaluated, not the time at which it is declared.