如图所示,在页面中加入了时间和日期显示,在安卓手机上可以正常显示时间,但是苹果手机却不显示,请问如何解决?
var that = this;
var now = new Date();
var a = now.getFullYear();
var b = now.getMonth() + 1;
var c = now.getDate(); //日期15
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate(); //日期15
var day = now.getDay(); //星期数
if (month < 10) { month = "0" + month };
if (date < 10) { date = "0" + date };
var date1 = new Date(a, parseInt(b) - 1, c);
var date2 = new Date(a, 0, 1);
var d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
var week_no= Math.ceil( (d + ((date2.getDay() + 1) - 1)) / 7 );
var today= year + "年" + month + "月" + date + "日";
var today_code = year + month + date;
var stamp_time_now = now.getTime(); //现在的时间戳
var time_115959 = year + "/" + month + "/" + date + " 11:59:59:999";
var stamp_time_115959 = new Date(time_115959).getTime(); //115959的时间戳
var wic_day;
var the_qty;
if(stamp_time_now > stamp_time_115959){ //显示 明日 午餐预定
wic_day = '明日';
var stamp_time = new Date(stamp_time_now + 50400000); //第二天的时间
year = stamp_time.getFullYear();
month = stamp_time.getMonth() + 1;
date = stamp_time.getDate(); //日期15
day = stamp_time.getDay(); //星期数
today= year + "年" + month + "月" + date + "日";
if (month < 10) { month = "0" + month };
if (date < 10) { date = "0" + date };
nextday_code = year + month + date;
that.setData({
day: day,
today:today,
wic_day:wic_day,
});
若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人
好像是这个的问题,你们干啥要精确到毫秒
好的,我试试哈!