js时间戳在ios上不兼容的解决方案

var timeStart = new Date('2018-06-08 00:00:00');
var timeEnd = new Date('2018-06-15 00:00:00');

var Astart = Date.parse(timeStart)/1000;
var Aend = Date.parse(timeEnd)/1000;
var arr = '2018-06-02 00:00:00'.split(/[- : \/]/),
arr2 = '2018-06-12 00:00:00'.split(/[- : \/]/),
date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]),
date2 = new Date(arr2[0], arr2[1]-1, arr2[2], arr2[3], arr2[4], arr2[5])
;

var Astart = Date.parse(date)/1000;
var Aend = Date.parse(date2)/1000;

第一部分为正常写法

第二部分为兼容写法

你可能感兴趣的:(前端基础)