The Date.parse
method is completely implementation dependent (new Date(string)
is equivalent to Date.parse(string)
).
I would recommend you to parse your date string manually, and use the Date constructor with the year, month and day arguments to avoid ambiguity:
// parse a date in yyyy-mm-dd format function parseDate(input) { var parts = input.split('-'); // new Date(year, month [, day [, hours[, minutes[, seconds[, ms]]]]]) return new Date(parts[0], parts[1]-1, parts[2]); // Note: months are 0-based }
Read full article from javascript Date.parse - Stack Overflow
No comments:
Post a Comment