formatDate()

Creates a string representation of the date using the specified format string.

This function is valid in v2.4.1 to v2.24.2. This function has been downloaded 62 times.

Parameters

{Date} date
Date object to be formatted as a string.
{string} strFormat
If part of the string is wrapped in single quotes, those single quotes will be removed, any groupings of 2 consecutive single quotes will be replaced with just one and the other characters will appear in the returned string as is. YYYY will be replaced by the full year (eg. 2018). YY will be replaced by a 2-digit representation of the year (eg. 18). MMMM will be replaced by the name of the month (eg. September). MMM will be replaced by the 1st 3 characters of the name of the month (eg. Sep). MM will be replaced by a 2-digit representation of the month (eg. 09). M will be replaced by a numeric representation of the month (eg. 9). DDDD will be replaced by the name of the day of the week (eg. Sunday). DDD will be replaced by the 1st 3 characters of the name of the day of the week (eg. Sun). DD will be replaced by a 2-digit representation of the day of the month (eg. 02). D will be replaced by a numeric representation of the day of the month (eg. 2). HH will be replaced with a 24-hour 2-digit representation of the hour (eg. 15). H will be replaced with a 24-hour numeric representation of the hour (eg. 15). hh will be replaced with a 12-hour 2-digit representation of the hour (eg. 03). h will be replaced with a 12-hour numeric representation of the hour (eg. 3). mm will be replaced with a 2-digit representation of the minutes (eg. 26). m will be replaced with a numeric representation of the minutes (eg. 26). ss will be replaced with a 2-digit representation of the seconds (eg. 01). s will be replaced with a numeric representation of the seconds (eg. 1). A will be replaced with "AM" or "PM". a will be replaced with "am" or "pm". SSS will be replaced with a 3-digit representation of the milliseconds (eg. 000). S will be replaced with a numeric representation of the milliseconds (eg. 0). Z will be replaced with a representation of the timezone offset that starts off with "+" or "-", followed by 2 digits that represent the hours offset, followed by 2 digits that represent the minutes offset.
{Object=} opt_overrides Optional
Object that can override the preset values. If the months property is defined it should be an array of 12 month names starting with January. If the days property is defined it should be an array of the 7 days of the week starting with Sunday.

Returns

{string}
A string representation of date where all of the rules for strFormat are followed.