{"id":31492,"date":"2018-04-21T15:47:47","date_gmt":"2018-04-21T15:47:47","guid":{"rendered":"https:\/\/ampscript.guide\/formatdate\/"},"modified":"2024-10-27T18:04:28","modified_gmt":"2024-10-27T18:04:28","slug":"formatdate","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/formatdate\/","title":{"rendered":"FormatDate"},"content":{"rendered":"<h2>FormatDate<\/h2>\n<p>This function formats a date\/time string in the specified format pattern and locale.<\/p>\n<h3>Arguments<\/h3>\n<p><code>FormatDate(1,2,3,4)<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">Ordinal<\/th>\n<th style=\"text-align: left;\">Type<\/th>\n<th style=\"text-align: left;\">Required<\/th>\n<th style=\"text-align: left;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">1<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">The date string to format<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">The output date format pattern (see table below for valid values)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">3<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">The output time format pattern  (see table below for valid values)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">4<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">The ISO locale code for the output<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These are the valid format patterns, given a date of <code>2017-09-15T16:07:08.1230000-06:00<\/code>:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Element<\/th>\n<th style=\"text-align: left;\">Format Pattern<\/th>\n<th style=\"text-align: left;\">Output<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">Long<\/td>\n<td style=\"text-align: left;\">l<\/td>\n<td style=\"text-align: left;\">Friday, September 15, 2017<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Short Date<\/td>\n<td style=\"text-align: left;\">s<\/td>\n<td style=\"text-align: left;\">9\/15\/2017<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Month Year<\/td>\n<td style=\"text-align: left;\">Y<\/td>\n<td style=\"text-align: left;\">September 2017<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Year<\/td>\n<td style=\"text-align: left;\">YY<\/td>\n<td style=\"text-align: left;\">17<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Year<\/td>\n<td style=\"text-align: left;\">YYYY<\/td>\n<td style=\"text-align: left;\">2017<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Month<\/td>\n<td style=\"text-align: left;\">M<\/td>\n<td style=\"text-align: left;\">September 15<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Month<\/td>\n<td style=\"text-align: left;\">MM<\/td>\n<td style=\"text-align: left;\">09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Month<\/td>\n<td style=\"text-align: left;\">MMM<\/td>\n<td style=\"text-align: left;\">Sep<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Month<\/td>\n<td style=\"text-align: left;\">MMMM<\/td>\n<td style=\"text-align: left;\">September<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Day<\/td>\n<td style=\"text-align: left;\">dd<\/td>\n<td style=\"text-align: left;\">15<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Day<\/td>\n<td style=\"text-align: left;\">dddd<\/td>\n<td style=\"text-align: left;\">Fri<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Day<\/td>\n<td style=\"text-align: left;\">ddddd<\/td>\n<td style=\"text-align: left;\">Friday<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Hour 12-hour<\/td>\n<td style=\"text-align: left;\">hh<\/td>\n<td style=\"text-align: left;\">06<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Hour 24-hour<\/td>\n<td style=\"text-align: left;\">HH<\/td>\n<td style=\"text-align: left;\">16<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Minutes<\/td>\n<td style=\"text-align: left;\">mm<\/td>\n<td style=\"text-align: left;\">07<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Seconds<\/td>\n<td style=\"text-align: left;\">ss<\/td>\n<td style=\"text-align: left;\">08<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Milliseconds (time only)<\/td>\n<td style=\"text-align: left;\">MM<\/td>\n<td style=\"text-align: left;\">123<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">AM\/PM<\/td>\n<td style=\"text-align: left;\">tt<\/td>\n<td style=\"text-align: left;\">PM<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Timezone offset<\/td>\n<td style=\"text-align: left;\">zz<\/td>\n<td style=\"text-align: left;\">-06<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Timezone offset<\/td>\n<td style=\"text-align: left;\">zzz<\/td>\n<td style=\"text-align: left;\">-06:00<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Short Time<\/td>\n<td style=\"text-align: left;\">s<\/td>\n<td style=\"text-align: left;\">4:07 PM<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>NOTE: Format patterns are not case-sensitive, but they must be used in the correct pattern argument (for example, both <code>mm<\/code> and <code>MM<\/code> are date <em>and<\/em> time formats).<\/p>\n<p>NOTE: This function returns lowercase month and day names for non-US culture codes by default.<\/p>\n<\/blockquote>\n<h3>Example<\/h3>\n<pre><code>%%[\n\nvar @dateString, @timeString, @dateISO, @dateRFC, @dateLong, @dateShort, @frFRDate, @monthYear, @yearShort, @yearFull, @monthNameDay, @monthNumber, @monthShortName, @monthFullName, @dayNumber, @dayShortName, @dayFullName, @hour, @minute, @seconds, @milliseconds, @AMPM, @offsetHours, @offsetHoursMinutes, @timeShort\n\nset @dateString = \"2017-09-15T16:07:08.1230000-06:00\"\nset @timeString = \"16:07:08.123\"\n\nset @dateISO  = FormatDate(@dateString,\"iso\")\nset @dateRFC  = FormatDate(@dateString,\"rfc\")\nset @dateLong  = FormatDate(@dateString,\"l\")\nset @dateShort  = FormatDate(@dateString,\"s\")\nset @frFRDate = properCase(FormatDate(@dateString,\"l\",\"\",\"fr-FR\"))\n\nset @monthYear = FormatDate(@dateString,\"Y\")\nset @yearShort = FormatDate(@dateString,\"YY\")\nset @yearFull = FormatDate(@dateString,\"YYYY\")\nset @monthNameDay = FormatDate(@dateString,\"M\")\nset @monthNumber = FormatDate(@dateString,\"MM\")\nset @monthShortName = FormatDate(@dateString,\"MMM\")\nset @monthFullName = FormatDate(@dateString,\"MMMM\")\nset @dayNumber = FormatDate(@dateString,\"dd\")\nset @dayShortName = FormatDate(@dateString,\"dddd\")\nset @dayFullName = FormatDate(@dateString,\"ddddd\")\n\nset @hour = FormatDate(@timeString,\"\",\"hh\")\nset @minute = FormatDate(@timeString,\"\",\"mm\")\nset @seconds = FormatDate(@timeString,\"\",\"ss\")\nset @milliseconds = FormatDate(@timeString,\"\",\"MMM\")\nset @AMPM = FormatDate(@timeString,\"\",\"tt\")\nset @offsetHours = FormatDate(@dateString,\"zz\")\nset @offsetHoursMinutes = FormatDate(@dateString,\"zzz\")\nset @timeShort = FormatDate(@timeString,\"\",\"s\")\n\n]%%\ndateString: %%=v(@dateString)=%%\n&lt;br&gt;dateISO: %%=v(@dateISO)=%%\n&lt;br&gt;dateRFC: %%=v(@dateRFC)=%%\n&lt;br&gt;dateLong: %%=v(@dateLong)=%%\n&lt;br&gt;dateShort: %%=v(@dateShort)=%%\n&lt;br&gt;frFRDate: %%=v(@frFRDate)=%%\n&lt;br&gt;&lt;br&gt;monthYear: %%=v(@monthYear)=%%\n&lt;br&gt;yearShort: %%=v(@yearShort)=%%\n&lt;br&gt;yearFull: %%=v(@yearFull)=%%\n&lt;br&gt;monthNameDay: %%=v(@monthNameDay)=%%\n&lt;br&gt;monthNumber: %%=v(@monthNumber)=%%\n&lt;br&gt;monthShortName: %%=v(@monthShortName)=%%\n&lt;br&gt;monthFullName: %%=v(@monthFullName)=%%\n&lt;br&gt;dayNumber: %%=v(@dayNumber)=%%\n&lt;br&gt;dayShortName: %%=v(@dayShortName)=%%\n&lt;br&gt;dayFullName: %%=v(@dayFullName)=%%\n&lt;br&gt;&lt;br&gt;timeString: %%=v(@timeString)=%%\n&lt;br&gt;hour: %%=v(@hour)=%%\n&lt;br&gt;minute: %%=v(@minute)=%%\n&lt;br&gt;seconds: %%=v(@seconds)=%%\n&lt;br&gt;milliseconds: %%=v(@milliseconds)=%%\n&lt;br&gt;AMPM: %%=v(@AMPM)=%%\n&lt;br&gt;offsetHours: %%=v(@offsetHours)=%%\n&lt;br&gt;offsetHoursMinutes: %%=v(@offsetHoursMinutes)=%%\n&lt;br&gt;timeShort: %%=v(@timeShort)=%%<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>dateString: 2017-09-15T16:07:08.1230000-06:00\ndateISO: 2017-09-15T16:07:08.1230000-06:00\ndateRFC: Fri, 15 Sep 2017 16:07:08 GMT\ndateLong: Friday, September 15, 2017\ndateShort: 9\/15\/2017\nfrFRDate: Vendredi 15 Septembre 2017\n\nmonthYear: September 2017\nyearShort: 17\nyearFull: 2017\nmonthNameDay: September 15\nmonthNumber: 09\nmonthShortName: Sep\nmonthFullName: September\ndayNumber: 15\ndayShortName: Fri\ndayFullName: Friday\n\ntimeString: 16:07:08.123\nhour: 16\nminute: 07\nseconds: 08\nmilliseconds: 123\nAMPM: PM\noffsetHours: -06\noffsetHoursMinutes: -06:00\ntimeShort: 4:07 PM<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>FormatDate This function formats a date\/time string in the specified format pattern and locale. Arguments FormatDate(1,2,3,4) Ordinal Type Required Description 1 String True The date string to format 2 String True The output date format pattern (see table below for valid values) 3 String False The output time format pattern (see table below for valid [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The AMPscript Guide - FormatDate<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ampscript.guide\/formatdate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - FormatDate\" \/>\n<meta property=\"og:description\" content=\"FormatDate This function formats a date\/time string in the specified format pattern and locale. Arguments FormatDate(1,2,3,4) Ordinal Type Required Description 1 String True The date string to format 2 String True The output date format pattern (see table below for valid values) 3 String False The output time format pattern (see table below for valid [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/formatdate\/\" \/>\n<meta property=\"og:site_name\" content=\"The AMPscript Guide\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-21T15:47:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-27T18:04:28+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ampscript.guide\/#website\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"The AMPscript Guide\",\"description\":\"The Definitive Scripting Manual for Salesforce Marketing Cloud\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ampscript.guide\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/formatdate\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/formatdate\/\",\"name\":\"The AMPscript Guide - FormatDate\",\"isPartOf\":{\"@id\":\"https:\/\/ampscript.guide\/#website\"},\"datePublished\":\"2018-04-21T15:47:47+00:00\",\"dateModified\":\"2024-10-27T18:04:28+00:00\",\"author\":{\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\"},\"breadcrumb\":{\"@id\":\"https:\/\/ampscript.guide\/formatdate\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/formatdate\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/formatdate\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/formatdate\/\",\"url\":\"https:\/\/ampscript.guide\/formatdate\/\",\"name\":\"FormatDate\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\",\"name\":\"dev\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31492"}],"collection":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/comments?post=31492"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31492\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}