javascript - new Date("2013-03-18 12:12:12")
PHP中文网
PHP中文网 2017-04-10 15:47:39
0
5
580

new Date("2013-03-18 12:12:12"),ios系统得到的为Invalid Date,这是为什么?应该怎么处理?

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
Steven东东

The content you want to restore from the network disk

  • reply Bad taste, no one in the crowd
    Steven东东 author 2019-11-21 18:19:16
黄舟

格式问题,不仅ios会说invalid,你在windows下也是一样的。

建议修改如下 someTime=new Date("2013-03-18T12:12:12");

  或者     anotherTime=new Date(2013,03,18,12,12,12);

注意月份中,实际是4月份哦,因为月份是从0开始的

刘奇
"2013-03-18 12:12:12".replace(/-/g, "/");

你再试试。

黄舟

这个是IOS的bug,
安卓下面可以用 new Date("2013/03/18 12: 12: 12")和new Date("2013-03-18 12: 12: 12")
但是IOS只能用new Date("2013/03/18 12 :12 :12")

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!