How can I insert the current date / time?

Docmosis has a built-in variable used to insert the current date and time:

<<$nowUTC>>

The output for the $nowUTC field will be the current date/time in ISO 8601 format.

2022-03-11T02:23:50Z

The format used for $nowUTC is also available using this variable:

<<$nowUTCFormat>>

The output for the above will be:

yyyy-MM-dd'T'HH:mm:ssX

The format of $nowUTC is one of the default formats of the Docmosis date functions such as dateFormat, dateAdd, and so on.

This means it is possible to pass $nowUTC to the dateFormat function, without having to specify the input format, as Docmosis will recognize it automatically.

For example: to display the current day of the week with the date, write the following line in the template:

<<{dateFormat($nowUTC, ‘EEEE, dd MMMM yyyy’)}>>

The output of this will be formatted like this:

Friday, 11 March 2022

For more information on working with dates please see the Template Guide.

 

Related items