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

注意两点便可:html

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

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

 

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('日', '');

转载于:https://www.cnblogs.com/zlbrother/p/8064551.htmlblog