Skip to main content
Version: 1.0.0

dateformats

Dateformat

format property in Schema facilitates defining any date-time format by using a rich set of tokens using which almost any date-format can be parsed in DataModel

A variable of type date-time can be specified in schema as:

{
name: 'name_of_variable',
type: 'dimension',
subtype: 'temporal'
}

Representation of date and time varies based on geo location and personal preference. DataModel is able to handle all kind of DateFormat possible. By default DataModel recognizes two date format automatically without specifying the format property in Schema.

  • Date in miliseconds from epoch date i.e. the result of new Date(2012, 10, 20).getDate()
  • JavaScript Date object.

For any other date format, the format needs to be specified in Schema:

[{
type: 'dimension',
subtype: 'temporal',
format: '%Y'
}]

Following are the tokens available to specify formats:

TokenDescriptionExample
%H24-hour format of an hour with leading zeros00 through 23
%I12-hour format of an hour with leading zeros01 through 12
%pUppercase Ante meridiem and Post meridiemAM or PM
%PLowercase Ante meridiem and Post meridiemam or pm
%MMinutes with leading zeros00 to 59
%SSeconds, with leading zeros00 to 59
%aA textual representation of a day, three lettersMon through Sun
%AA full textual representation of the day of the weekSunday through Saturday
%eDay of the month without leading zeros1 to 31
%dDay of the month, 2 digits with leading zeros01 to 31
%bA short textual representation of a month, three lettersJan through Dec
%BA full textual representation of a month, such as January or MarchJanuary to December
%mNumeric representation of a month, with leading zeros01 through 12
%yA two digit representation of a year90 for 1990
%YA full numeric representation of a year, 4 digits1990

Example: In order to make DataModel recognize 1990-Sep/25 the format specification will be %Y-%b/%e Here % is a token identifier.