Reputation: 37034
In js I write following row:
new Date("2014-12-01 00:20:00.0")
In chrome it works good but in Mozilla I see error Invalid Date
this string comes to me from another function thus I cannot change it.
Hwow can I set Date format for this constructor?
Upvotes: 0
Views: 62
Reputation: 4020
So, I have the solution. After reading this
I found a supported Format, which is near to yours. ECMAScript 5 ISO-8601 format. "2011-10-10T14:48:00"
So if you do this before parsing, it will work.
<script>
d1 = new Date("2014-12-01 00:20:00.0".replace(/ /g, "T"));
alert(d1);
</script>
Checked with FF, IE, OP and Chrome!
Upvotes: 2
Reputation: 821
Checking the MDN documentation Date :
new Date(year, month[, day[, hour[, minute[, second[, millisecond]]]]]);
For your case :
new Date(2014, 12, 01, 0, 20, 0, 0);
Upvotes: 0