DateFormat()
Formats a date using the specified date, time zone, and pattern. This function takes a date and two string values as arguments and returns the date as a formatted string value. It does not include the time. If you need to format the date so that it includes the time, use the DateTimeFormat() function.
Syntax
DateFormat(<date>, <time_zone>, <pattern>)
Input
date
date
The date to format.
time_zone
string
(Optional) The time zone code. This argument specifies the time zone of the date. For example, if you want the date to be in Eastern Standard Time (EST), enter the time zone argument "EST"
. If you do not specify a time zone, the local time zone of the user who is completing the form is used.
pattern
string
(Optional) The pattern used to format the date. This argument specifies the format that you want the date to be displayed in. For example, if you want to display the date as two-digit numbers separated by slashes, enter the pattern argument "dd/mm/yy"
. If you do not specify a pattern, the default pattern applied is "MMMM d, yyyy"
.
Output
string
Examples
Assume that you have a form in which there is a date field question with the reference name date_of_birth. In the field, the user chooses January 31, 2000. The user is in the EST time zone.
- The expression DateFormat($date_of_birth) returns
"January 31, 2000"
. - The expression DateFormat($date_of_birth, "PST") returns
"January 30, 2000"
, because in this example the time zone argument changes the specified date to Pacific Standard Time, which is January 30, 2000. - The expression DateFormat($date_of_birth, "EST", "dd/mm/yyyy") returns
"31/01/2000"
.