Categories

jQuery.i18n.formatDate()

Categories: Utilities | Internationalisation

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

Plugin: jQuery.i18n

Description: Get a formated string from a Javascript Date object.

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

    version added: 1.0

    value   A Javascript Date object.

    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.formatDate() method returns a formated string representing a date from a Javascript Date object.

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'T'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 formated string from a Javascript Date object.

    Code:
    $.i18n.formatDate( new Date(2010,1,15,12,30,0), "l" );
    Results:
    2/15/2011 12:30 PM
  • Get a german formated string from a Javascript Date object.

    Code:
    $.i18n.formatDate( new Date(2010,1,15,12,30,0), "l", {region:'de-DE'} );
    Results:
    15.02.2011 12:30
  • 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'