Open suoutsky opened 6 years ago
var d = new Date("2015-12-31 00:00:00"); console.log(d.getDate() + '. ' + d.getMonth() + ' ' + d.getFullYear(); Result for Android:
31.11 2015 Result on iOS:
NaN. NaN NaN
to fixed it: var dateString = "2015-12-31 00:00:00"; var d = new Date(dateString.replace(/-/g, '/'));
解决方案: var dateString = "2015-12-31 00:00:00"; var d = new Date(dateString.replace(/-/g, '/'));
详细文档:http://www.iamaddy.net/2015/02/ios-javascript-date/
var d = new Date("2015-12-31 00:00:00"); console.log(d.getDate() + '. ' + d.getMonth() + ' ' + d.getFullYear(); Result for Android:
31.11 2015 Result on iOS:
NaN. NaN NaN
to fixed it: var dateString = "2015-12-31 00:00:00"; var d = new Date(dateString.replace(/-/g, '/'));