闻心阁

一蓑烟雨看苍生,半壶浊酒笑红尘

Date.parse() method not work in IOS

2016-11-25 约 1 分钟读完 搬砖秘籍

Maybe it’s a big bug that I had experienced recently, when I use JavaScript method Date.parse('2016-10-24 18:36'), two different outputs in Android and IOS. In Android it output the right timestamp which i need, but in IOS, it can not get the timestamp.

How To Fixed it

Just use the ISO 8601 format, it works well, for example:

var a = Date.parse('2016-11-25T16:11:00Z');
console.log(a);

This code can run in both Android and IOS.