(一)IOS new Date()

IOS使用new Date()会出现 Invalid Date、NaN-NaN等情况

原因:new Date(),new Date('2019-01-01'),new Date('2019-01-01 0:00:00')在IOS中不支持

但new Date('2019-01-01T0:00:00')格式在IOS中支持

public dates: Array<Date> = [];
this.dates.push(new Date('2019-08-25T15:29:44.459086'));
this.dates.push(new Date('2019-08-26 00:00:00'));
this.dates.push(new Date('2019-08-27'));
this.dates.push(new Date(Date.parse('2019-08-25T15:29:44.459086')));
this.dates.push(new Date(Date.parse('2019-08-26 00:00:00')));
this.dates.push(new Date(Date.parse('2019-08-27')));
this.dates.push(new Date(Date.parse('2019-08-25T00:00:00.000000')));
this.dates.push(new Date(Date.parse('2019-08-26T00:00:00.00000')));
this.dates.push(new Date(Date.parse('2019-08-27T00:00:00.000000Z')));
this.dates.push(new Date(Date.parse('2019-08-28T00:00:00.00000Z')));
this.dates.push(new Date(Date.parse('2019-08-29T00:00:00.000Z')));
this.dates.push(new Date());
let curr = new Date();
let str = `${TimeHelper.Date2String(curr, 'YYYY-MM-DD')}T00:00:00.000000`;
curr = new Date(Date.parse(str));
console.log(str);
this.dates.push(curr);
this.dates.push(new Date(new Date().toDateString()));
this.dates.push(new Date(`${TimeHelper.Date2String(new Date(), 'YYYY-MM-DD')}`));
this.dates.push(new Date(Date.parse('2019-08-26')));
原文地址:https://www.cnblogs.com/chendongbky/p/11416744.html