js怎么判断有没有过了今天下午三点?

小程序 文章 2020-08-12 18:41 648 0 全屏看文

AI助手支持GPT4.0

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?

回答:

谋谋谋:

百度啥都有 一搜一大堆

They Say:

建议使用时间库moment.js

let hour = moment().format('HH')if (hour >= 15) {  console.log("过了下午三点了");} else {  console.log("还没到下午三点");}
Distance:
let hour = new Date().getHours()if (hour > 15) {  console.log("过了下午三点了");} else {  console.log("还没到下午三点");}
They Say:等于呢?
Distance:过了三点,你觉得还包括三点吗?
They Say:我的意思是 >= 15 都是过了下午三点,你的if else 会判定,15:00:01 -15:59:5之间为 没到下午三点,你觉得对吗?
Q:

建议使用时间库,dayjs

-EOF-

AI助手支持GPT4.0