Search code examples
javascriptdatejs

Extend datejs to parse string 25 Apr 2013 1200


How can I Extend datejs to parse "25 Apr 2013 1200" ?


Solution

  • I guess you need to use Date.parseExact:

    Date.parseExact ( String dateString, String formatStringOrArray ) : Date

    Converts the specified string value into its JavaScript Date equivalent using the specified format (string) or formats (array). The format of the string value must match one of the supplied formats exactly.

    Example:

    Date.parseExact("25 Apr 2013 1200", "d MMM yyyy Hm");
    

    REF: https://code.google.com/p/datejs/wiki/APIDocumentation#parseExact