AMPscript System Time and Date Strings

You can use the system date and time strings to output or log the date.

For emails and SMS messages, the values of time and date strings are fixed to the date on which the messages were sent. For CloudPages, the values of time and date strings are based on the date on which the page was rendered.

String Description Example
xtmonth The full name of the month. August
xtmonthnumeric The month expressed as a number from 1-12. 8
xtday The day of the month, expressed as a number. 5
xtdayofweek The day of the week. Saturday
xtyear The year, expressed in four digits 2023
xtshortdate The full date in short format. 08/05/2023
xtlongdate The full date in long format. Saturday, August 5, 2023

Using Time and Date Strings with AMPscript Functions

You can combine system date strings with AMPscript functions. This example shows how to change the way that the system date is presented using the FormatDate() function.

<p>This email was sent %%=v(xtdayofweek)=%%, %%=FormatDate(xtlongdate, "d MMMM YYYY")=%%.</p>

This example outputs the day, month, and year in the specified format:

This email was sent Saturday, 5 August 2023.

See Also