当前位置 : 主页 > 手机开发 > ios >

(一)IOS new Date()

来源:互联网 收集:自由互联 发布时间:2021-06-11
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-01 T 0:00:00‘)格式在IOS中支持 public dates: A

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‘)));
网友评论