Date

The Date element inserts the current system date, optionally making it dynamic so that it updates whenever the template is viewed or produces output.

Adding a date

To add a Date element, use the Insert > Date option in the menus. A dialog appears with the following controls:

  • Language: Use the drop-down to select which language the date should be displayed in.

  • Update Automatically: Check to update the date automatically when the template is viewed or produces output. If the section is set to evaluate Handlebars expressions, an expression is inserted in the text (see Date: today). Otherwise a placeholder is inserted in the template and a script is created to update it automatically.

    Note: To make the software insert expressions instead of placeholders, right-click the section in the Resources pane, select Properties and check the option Evaluate Handlebars expressions.

    If the Update Automatically option is not checked, a static text with the current date is inserted.

  • Available Formats: Select the date/time format in which to display the date.

Click OK to insert the date or Cancel to close the dialog.

Tip: If you are looking to add a date that originates from a record set, to a template, see: Variable data in the text. To insert a date you could use either the drag and drop method or the Wizard.

Changing the date

Once inserted, a date can be modified directly in the template (if it does not update automatically) or through the date script (if it does update automatically). To modify the date in the script:

  1. Double-click the date script in the Scripts pane.

  2. Between the round brackets after Date, enter the desired date in the following order: year, month, day, and optionally hours, minutes, seconds, milliseconds (see MDN Web Docs - Date object.) When the time is omitted, it defaults to 12:00:00 AM.

Formatting an automatically updating date

In the expression that adds the date, you can change the format by replacing the Helper (e.g. dateShort, dateMedium) with another one. For a list of date format Helpers, see: Date and time Helpers.

If the date is inserted by a script, it uses the short date format. To change this:

  1. Double-click the date script in the Scripts pane.

  2. Delete the first line of the script.

  3. On the second line, delete what comes after format and change format to formatter (see formatter).

  4. Now type a dot after formatter, press Ctrl + space and choose one of the functions to format a date and time; see Date, date/time and time functions.

Note: The Locale, set in the Edit > Locale dialog, has an influence on the formatting of a date. The Locale can be the system's locale, a specific locale, or it can depend on the value of a data field or runtime parameter; see Locale.