Categories

jQuery.i18n.parseDate()

Categories: Utilities | Internationalisation

jQuery.i18n.parseDate( value, format, [ options ] )Returns: Date object

Plugin: jQuery.i18n

Description: Get a Javascript Date object from formated string.

  • jQuery.i18n.parseDate( value, format, [ options ] )

    version added: 1.0

    value   An formated date string.

    format   A token string to specify the format.

    options   A set of key/value pairs that configure the i18n call. A default are set for any option by jQuery.i18n.settings.

The jQuery.i18n.parseDate() method parses a string representing a date into a JavaScript Date object, taking the given format.

Shortcut tokens with their meaning and example (en):
  • d Short Date M/d/yyyy
  • D Long Date dddd, MMMM dd, yyyy
  • l Date, Short Time M/d/yyyy h:mm tt
  • L Date, Long Time M/d/yyyy h:mm:ss tt
  • f Long Date, Short Time dddd, MMMM dd, yyyy h:mm tt
  • F Long Date, Long Time dddd, MMMM dd, yyyy h:mm:ss tt
  • t Short Time h:mm tt
  • T Long Time h:mm:ss tt
  • Y Month/Year MMMM, yyyy
  • M Month/Day yyyy MMMM
  • S Sortable format, is always the same for every region yyyy'/'MM'/'dd' 'HH':'mm':'ss
More specific tokens with their meaning and example:
  • d Day of month (no leading zero) 5
  • dd Day of month (leading zero) 05
  • ddd Day name (abbreviated) Sat
  • dddd Day name (full) Saturday
  • M Month of year (no leading zero) 9
  • MM Month of year (leading zero) 09
  • MMM Month name (abbreivated) Sept
  • MMMM Month name (full) September
  • yy Year (two digits) 55
  • yyyy Year (four digits) 1955
  • 'literal' Literal Text 'Hmmmm'...
  • \' Single Quote
  • m Minutes (no leading zero) 9
  • mm Minutes (leading zero) 09
  • h Hours (leading zero) 6
  • hh Hours (leading zero) 06
  • H Hours (24 hour time, no leading zero) 5 (5am) 15 (3pm)
  • HH Hours (24 hour time, leading zero) 05 (5am) 15 (3pm)
  • s Seconds (no leading zero) 9
  • ss Seconds (leading zero) 09
  • f Deciseconds 1
  • ff Centiseconds 11
  • fff Milliseconds 111
  • t AM/PM indicator (first letter) A or P
  • tt AM/PM indicator (full) AM or PM
  • z Timezone offset (hours only, no leading zero) -8
  • zz Timezone offset (hours only, leading zero) -08
  • zzz Timezone offset (full hours/minutes) -08:00
  • g or gg Era name A.D.
  • Get a Date object from date string.

    Code:
    $.i18n.parseDate( "2011-02-15T12:30:00", "yyyy'-'MM'-'dd'T'HH':'mm':'ss" );
    
    // or
    
    $.i18n.parseDate( "2/15/2011 12:30 PM", "l" );
    Results:
    Date object // Tue Feb 15 2011 12:30:00 GMT+0100 (CET)
  • Get a Date object from german date string.

    Code:
    $.i18n.parseDate( "2011-02-15T12:30:00", "yyyy'-'MM'-'dd'T'HH':'mm':'ss", {region:'de-DE'} );
    
    // or
    
    $.i18n.parseDate( "15.02.2011 12:30", "l", {region:'de-DE'} );
    Results:
    Date object // Tue Feb 15 2011 12:30:00 GMT+0100 (CET)
  • calendar

    version added: 1.0

    An available calender of the selected region.

    Default: 'standart'

  • region

    version added: 1.0

    A combination of an ISO 639 two-letter lowercase culture code for the language (and a two-letter uppercase code for the country or region).

    Default: 'en'