glize/formatters/date

Requires

Members

(inner, constant, non-null) NUMBER_FORMAT :Object.<string, function(!Date): number>

Static number formats that do not require parsing of the input string.
Properties:
Name Type Description
YYYYMMdd Object.<string, function(!Date): number>
YYYYMMddhhmm Object.<string, function(!Date): number>
YYYYMMddhhmmss Object.<string, function(!Date): number>
Source:
Type:
  • Object.<string, function(!Date): number>

Methods

(static) formatDate(datenon-null, format) → {string}

Formats given date according to given format.
Source:
Parameters:
Name Type Description
date Date The date to be formatted.
format string The date format.
Returns:
Type:
string
Returns formatted date as string.
Example
formatDate(new Date(), 'YYYY-MM-dd');
formatDate(new Date(), 'YYYY-MM-dd hh:mm');
formatDate(new Date(), 'dd MMM, YYYY');

(static) parseDate(str, format) → (nullable) {Date}

Parses given date str according to given format.
Source:
Parameters:
Name Type Description
str string The date string to be parsed.
format string The date format.
Returns:
Type:
Date
The parsed date.
Example
parseDate('2013-01-31', 'YYYY-MM-dd');
parseDate('2013-01-31 20:30', 'YYYY-MM-dd hh:mm');
parseDate('03 Jan, 2013', 'dd MMM, YYYY');