Skip to content Skip to sidebar Skip to footer

Date Casting In Javascript

alert(new Date('8/14/2012 4:24:34 PM')); Tue Aug 14 2012 16:24:34 GMT+0800 (Malay Peninsula Standard Time) alert(new Date('14/08/2012 4:31:29 PM')); Invalid Date I tried date.pa

Solution 1:

How about a quick swap using a regular expression?

alert(newDate("14/08/2012 4:31:29 PM".replace(/^(\d+)\/(\d+)/,'$2/$1')));

Solution 2:

Rather than Date.parseExact have you tried using Date.parse function provided by the datejs library like so

Date.parse("14/08/2012 4:31:29 PM")

Post a Comment for "Date Casting In Javascript"