How to convert string to timestamp and date in JS. here am using Date.parse(), but its not working in IE and FF. My code is..
in chrome its working fine.
var str = "05-Sep-2013 01:05:15 PM ";
console.log( Date.parse( str ) );
console.log( Date.parse( str.replace(/-/g, '/') ) ); // 1378404315000
in IE its returns
console.log( Date.parse( str.replace(/-/g, '/') ) ); // NaN
Please help me. thanks in advance.
don't replace the '-' with '/', use whitespace instead.
var str = "05-Sep-2013 01:05:15 PM ";
console.log( Date.parse( str.replace(/-/g, ' ') ) );
that works for me in IE
have a look at w3schools - they're working with whitespaces :)