Formats date to a string based on the requested format.
format string can be composed of the following elements:
'yyyy': 4 digit representation of year e.g. 2010
'yy': 2 digit representation of year, padded (00-99)
'MM': Month in year, padded (01‒12)
'M': Month in year (1‒12)
'dd': Day in month, padded (01‒31)
'd': Day in month (1-31)
'HH': Hour in day, padded (00‒23)
'H': Hour in day (0-23)
'hh': Hour in am/pm, padded (01‒12)
'h': Hour in am/pm, (1-12)
'mm': Minute in hour, padded (00‒59)
'm': Minute in hour (0-59)
'ss': Second in minute, padded (00‒59)
's': Second in minute (0‒59)
'a': am/pm marker
'Z': 4 digit (+sign) representation of the timezone offset (-1200‒1200)
Usage
In HTML Template Binding
{{
date_expression
| date:format }}
In JavaScript
angular.filter.date(date, format);
Parameters
date –
{(Date|number|string)}
– Date to format either as Date object, milliseconds (string or
number) or ISO 8601 extended datetime string (yyyy-MM-ddTHH:mm:ss.SSSZ).
format –
{string=}
– Formatting rules. If not specified, Date#toLocaleDateString is used.
Returns
{string} Formatted string or the input if input is not recognized as date/millis.