Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 979 Bytes

parse-date.md

File metadata and controls

40 lines (27 loc) · 979 Bytes

.parseDate( value, pattern )

Parse a string representing a date into a JavaScript Date object according to the given pattern.

Important: Use .dateParser( pattern ) instead when parsing more then one date, for improved performance.

Parameters

value

String with date to be parsed, eg. "11/1/10, 5:55 PM".

pattern

See .dateFormatter( pattern ).

Example

You can use the static method Globalize.parseDate(), which uses the default locale.

Globalize.locale( "en" );
Globalize.parseDate( "1/2/13", { date: "short" } );
// Wed Jan 02 2013 00:00:00

Globalize.locale( "es" );
Globalize.parseDate( "1/2/13", { date: "short" } );
// Fri Feb 01 2013 00:00:00

You can use the instance method .parseDate(), which uses the instance locale.

var ar = new Globalize( "ar" );
ar.parseDate( "٢‏/١‏/٢٠١٣ ١٢،٠٠ ص" , { date: "short" } );
// Wed Jan 02 2013 00:00:00