同求 Java 返回的格林时间, 在ios上用普通的方法没法转换成时间戳 , 求解 @官方
var newDate = GMTToStr(2018-08-21T01:52:36.000+0000, 'Y/M/D h:m:s').replace(/-/g, '/')
function GMTToStr(time){
console.log(time)
let date = new Date(time)
let Str = date.getFullYear() + '-' +
(date.getMonth() + 1) + '-' +
date.getDate() + ' ' +
date.getHours() + ':' +
date.getMinutes() + ':' +
date.getSeconds()
console.log(Str)
return Str
}
ios返回null
Note: parsing of date strings with the
Date
constructor (andDate.parse
, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
因为浏览器之间的差异和不兼容,强烈建议不要使用 用Date构造器(或者 Date.parse,他们是等价的) 生成的 date 字符串来做解析
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
好的 明白了