求助关于时间JS出现NaN错误var today=new Date();var hours = today.getHours();var minutes = today.getMinutes();var seconds = today.getSeconds();var timeValue = " " + ((hours >12) "下午 "+hours -12 :"上午 "+hours); timeValue += ((minutes <

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/14 23:37:06
求助关于时间JS出现NaN错误vartoday=newDate();varhours=today.getHours();varminutes=today.getMinutes();varseconds

求助关于时间JS出现NaN错误var today=new Date();var hours = today.getHours();var minutes = today.getMinutes();var seconds = today.getSeconds();var timeValue = " " + ((hours >12) "下午 "+hours -12 :"上午 "+hours); timeValue += ((minutes <
求助关于时间JS出现NaN错误
var today=new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var timeValue = " " + ((hours >12) "下午 "+hours -12 :"上午 "+hours); timeValue += ((minutes < 10) ":0" :":") + minutes+" ";
调用时分钟没问题,但是小时出现NaN,请问需要怎么修改?

求助关于时间JS出现NaN错误var today=new Date();var hours = today.getHours();var minutes = today.getMinutes();var seconds = today.getSeconds();var timeValue = " " + ((hours >12) "下午 "+hours -12 :"上午 "+hours); timeValue += ((minutes <
// hours - 12 用括号括起来

var timeValue = " " + ((hours >12) ? "下午 "+ (hours -12) : "上午 "+hours);