问题
I am facing this issue with javascript, I get yyyy-mm-dd dates from a database, but when I want to get the number of the week with getDay(), I get a wrong number if the day is with leading zero
I wrote a posible solution to parse MySql date into Javascript Date
function parseDate(str){
var dt=str.replace(/[-T:]/g," ").split(" ");
return new Date(dt[0],dt[1]-1,dt[2],dt[3]|0,dt[4]|0,dt[5]|0);
}
parseDate("2018-02-08");
//Thu Feb 08 2018 00:00:00 GMT-0600
parseDate("2018-02-08 22:30:00");
//Thu Feb 08 2018 22:30:00 GMT-0600
来源:https://stackoverflow.com/questions/48696566/getday-return-wrong-day-if-day-is-with-leading-zero