js怎么判断有没有过了今天下午三点?
js怎么判断有没有过了今天下午三点?How does js judge whether it has passed three o'clock this afternoon?
js怎么判断有没有过了今天下午三点?js怎么判断有没有过了今天下午三点?
How can JS judge if it is past three o'clock this afternoon?
回答:
建议使用时间库moment.js
let hour = moment().format('HH')if (hour >= 15) { console.log("过了下午三点了");} else { console.log("还没到下午三点");}
let hour = new Date().getHours()if (hour > 15) { console.log("过了下午三点了");} else { console.log("还没到下午三点");}
建议使用时间库,dayjs
原文出处:js怎么判断有没有过了今天下午三点?
百度啥都有 一搜一大堆