AMPscript Date and Time Formatting

AMPscript assumes all date datatype values use en-US or UTC formatting. You can output several different date and time formats with AMPscript, depending on your needs.

We recommend using the Format() function for date and time formatting that requires a locale setting.

This table shows available formats for both the Format() and FormatDate() functions, illustrated by the subsequent examples. For a longer table of available tokens and formats, review AMPscript Date and Time Formats: Format() and FormatDate().

This table demonstrates the available formats:

Year (Example: 2011)Month (Example: August)Date (Example: Monday, August 15)Hours (Example: 20)Minutes (Example: :00)Seconds (Example: :05)AM/PM (Example: PM)Offset (Example: -6:00)
y = 11M = 8d = 15h = 8m = 0s = 5t = Pz = -6
yy = 11MM = 08dd = 15hh = 08mm = 00ss = 05tt = PMzz = -06
yyy = 2011MMM = Augdddd = MonH = 8---zzz = -06:00
yyyy = 2011MMMM = Augustddddd = MondayHH = 20----

The output for M varies depending on whether M is used in a single function or within a group of functions.

The M variable in a single function displays as a numeral.

As a single M within a group of functions, the result is the full name of the month and the date in two-digit format. If you use the % character with the M variable in a group of functions, the M variable displays output as if it were in a single function.

There are no functions to set the timezone property of the dateTime value.

  • The Format() function doesn't specify timezones.
  • Choosing a Locale does not affect the timezone.
  • The use of zzz is not useful in the context of timezones, because the timezone value is always the server timezone.

The customer can calculate the dateTime value for a different offset, or use the SystemDateToLocalDate() function.

The next example takes the results of the Now() function, and returns three different formats.



This example below takes the results of the Now() function and returns it in the specified format.

%%=Format(Now(), "MMMM d, yyyy")=%%


%%=FormatDate(Now(), "MMMM d, yyyy")=%%

Result: August 15, 2011

This example formats a date and returns it in the specified format:

%%=Format("2011-08-15 20:00:05.567890", "MMM dd, yyyy", "Date", "en-US")=%%


%%=FormatDate("2011-08-15 20:00:05.567890", "MMM dd, yyyy", "l", "en-US")=%%

Result: Aug 15, 2011 8:00:05.PM

This example takes the value of Now(), offsets it using the DateAdd() function, and then returns that value in the specified format.


Given that the date is August 15, 2011, The output would be: Date: August 26, 2011.

This example outputs the Birthday attribute of a subscriber, from all subs or the sendable data extension in the specified format.


Given a Birthday attribute equal to August 15, 2011, The output would be: 15/08/2011