日期在苹果手机上显示NaN的处理方法

注意两点即可:

  1.苹果只认识 yyyy/mmmm/dddd/  这类格式的日期

  2.如果输出后还要进行处理日期对比,苹果默认会带中文字,如:年月日,需要转成上面1当中的日期格式在转时间戳进行比较

 

GetDateDiff(checked_in) {
//将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式
checked_in = checked_in.replace(/\-/g, "/");
return checked_in
}
 
转换好的日期带进来,在转换成上面第一种的格式,才能转出对应的时间戳。
new Date(datatime).toLocaleDateString().replace('年', '/').replace('月', '/').replace('日', '');
posted @ 2017-12-19 11:14  编程让我快乐  阅读(587)  评论(0编辑  收藏  举报