jQuery.i18n.expStrDate()
Categories: Utilities | Internationalisation
jQuery.i18n.expStrDate( format, [ strict ], [ options ] )Returns: String
Plugin: jQuery.i18n
Description: Get a string representing a regualar expression for a date format.
-
jQuery.i18n.expStrDate( format, [ strict ], [ options ] )
version added: 1.0format A token string to specify the format.
strict A boolean indication whether the use format in strict mode.
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.expStrDate()
method returns a string representing a regualar expression for the specified date 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'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.
The strict mode
If jQuery.i18n are running in strict mode, methods differentiate hard in some cases.
Strict mode ,format tokens:
- yyyy is not yy
- MM is not M
- dd is not d
- HH is not H
- mm is not m
- ss is not s
Non strict mode, format tokens:
- yyyy accept yy
- MM accept M
- dd accept d
- HH accept H
- mm accept m
- ss accept s
-
Get a regualar expression string for a specified date format.
Code:
$.i18n.expStrDate( "n" );
Results:
(0[1-9]{1}|[1-2]{1}\d{1}|3[0-1]{1})\.(0[1-9]{1}|1[0-2]{1})\.(\d{4})\s+(0\d{1}|1\d{1}|2[0-3]{1}):([0-5]{1}\d{1})
-
Get a regualar expression string for a specified date format in strict mode.
Code:
$.i18n.expStrDate( "n", true );
Results:
([1-9]{1}|1[1-2]{1})(\/)([1-9]{1}|[1-2]{1}\d{1}|3[0-1]{1})(\/)(\d{4})\s+([1-9]{1}|1[0-2]{1}):([0-5]{1}\d{1})\s+(AM|am|AM|PM|pm|PM)
-
Get a regualar expression string for a specified german date format.
Code:
$.i18n.expStrDate( "n", {region: "de-DE"} );
Results:
(0[1-9]{1}|[1-2]{1}\d{1}|3[0-1]{1})\.(0[1-9]{1}|1[0-2]{1})\.(\d{4})\s+(0\d{1}|1\d{1}|2[0-3]{1}):([0-5]{1}\d{1})
-
Get a regualar expression string for a specified german date format in strict mode.
Code:
$.i18n.expStrDate( "n", true, {region: "de-DE"} );
Results:
(0[1-9]{1}|[1-2]{1}\d{1}|3[0-1]{1})\.(0[1-9]{1}|1[0-2]{1})\.(\d{4})\s+(0\d{1}|1\d{1}|2[0-3]{1}):([0-5]{1}\d{1})