jQuery.i18n()
Categories: Utilities | Internationalisation
jQuery.i18n( type, value, [ options ] )Returns: String
Plugin: jQuery.i18n
Description: Get a formated date/number from Date/Number object.
-
jQuery.i18n( type, value, [ options ] )
version added: 1.0type A type for a date/number.
value An Date/Number object.
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()
method is a shortcut to format a date or number and supports only the standart types.
Standart types with their full formats (Example: en):
- date or d
M/d/yyyy
- dateLong or D => dddd, MMMM dd, yyyy>>
- dateLong-time or f
dddd, MMMM dd, yyyy h:mm tt
- dateLong-timeLong or F
dddd, MMMM dd, yyyy h:mm:ss tt
- date-time or l
M/d/yyyy h:mm tt
- date-timeLong or L
M/d/yyyy h:mm:ss tt
- time or t
h:mm tt
- timeLong or T
h:mm:ss tt
- currency or c
c2
- number or n
n2
- percent or p
p2
-
Get a formated date.
Code:
$.i18n( "d", new Date(2011, 1, 15) ); // or $.i18n( "date", new Date(2011, 1, 15) );
Results:
2/15/2011
-
Get a formated date in german.
Code:
$.i18n( "d", new Date(2011, 1, 15), {region:"de"} );
Results:
15.02.2011
-
Get a formated number with percent.
Code:
$.i18n( "p", 25.50 );
Results:
25.50 %
-
Get a formated number with percent in german.
Code:
$.i18n( "p", 25.50, {region:"de"} );
Results:
25,50 %
jQuery.i18n( type, value, [ options ] )Returns: String
Plugin: jQuery.i18n
Description: Get a Date/Number object from formated string.
-
jQuery.i18n( type, value, [ options ] )
version added: 1.0type A type for a date/number.
value An date or a number string.
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()
method is a shortcut to get a Date/Number object from a formated string and supports only the standart types.
Standart types with their full formats (Example: en):
- date or d
M/d/yyyy
- dateLong or D => dddd, MMMM dd, yyyy>>
- dateLong-time or f
dddd, MMMM dd, yyyy h:mm tt
- dateLong-timeLong or F
dddd, MMMM dd, yyyy h:mm:ss tt
- date-time or l
M/d/yyyy h:mm tt
- date-timeLong or L
M/d/yyyy h:mm:ss tt
- time or t
h:mm tt
- timeLong or T
h:mm:ss tt
- currency or c
c2
- number or n
n2
- percent or p
p2
-
Get a Date object from date string.
Code:
$.i18n( "d", "2/15/2011" ); // or $.i18n( "date", "2/15/2011" );
Results:
Date object // Tue Feb 15 2011 00:00:00 GMT+0100 (CET)
-
Get a Date object from german date string.
Code:
$.i18n( "d", "15.02.2011", {region:"de"} );
Results:
Date object // Tue Feb 15 2011 00:00:00 GMT+0100 (CET)
-
Get a Number object from percent string.
Code:
$.i18n( "p", "25.50 %" );
Results:
25.50
-
Get a Number object from german percent string.
Code:
$.i18n( "p", "25,50 %", {region:"de"} );
Results:
25.50