console.log(newDate(0));VM655237:1ThuJan01197008:00:00GMT+0800(中国标准时间)console.log(newDate("0"));VM655252:1SatJan01200000:00:00GMT+0800(中国标准时间)
2 回答
慕桂英4014372
TA贡献1871条经验 获得超13个赞
参数是字符串的时候,会使用Date.parse,而其中咋解释字符串"0"是实现自己定义的。这与参数是数字的时候完全不同。TheparsefunctionappliestheToStringoperatortoitsargument.IfToStringresultsinanabruptcompletiontheCompletionRecordisimmediatelyreturned.Otherwise,parseinterpretstheresultingStringasadateandtime;itreturnsaNumber,theUTCtimevaluecorrespondingtothedateandtime.TheStringmaybeinterpretedasalocaltime,aUTCtime,oratimeinsomeothertimezone,dependingonthecontentsoftheString.ThefunctionfirstattemptstoparsetheStringaccordingtotheformatdescribedinDateTimeStringFormat(20.3.1.15),includingexpandedyears.IftheStringdoesnotconformtothatformatthefunctionmayfallbacktoanyimplementation-specificheuristicsorimplementation-specificdateformats.Stringsthatareunrecognizableorcontainout-of-boundsformatfieldvaluesshallcauseDate.parsetoreturnNaN.
添加回答
举报
0/150
提交
取消