后端返回的数据格式为:2021-12-15 20:16:34
IOS系统只识别 " / " 不识别 " - ".
并且Android可以兼容掉空格,但苹果会老老实实读出来
var time = ‘2021-12-15 20:16:34’;
不兼容的代码是:var newDate = new Date(time );
兼容性代码:var time = time && (time ).replace(/-/g,’/’);
var newDate = new Date(time );
var time = ‘2021-12-15T17:49:29.000+0800’;
var date= time.substr(0, 19); //‘2021-12-15T17:49:29’
var newDate = new Date(date.replace(/T/g, ’ ').replace(/-/g, ‘/’));
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)