繁体   English   中英

如何在反应 js 或 javascript 中仅显示上午 9 点到下午 5 点之间的时间?

[英]How to show button only the time between 9am to 5pm in react js or javascript?

假设我有一个按钮应该只在特定时间段(上午 9 点到下午 5 点)显示,否则按钮不应该显示。

仅当时间在 9:00 到 17:00(下午 5 点)之间时才输入if语句。

 const date = new Date(); const hours = date.getHours(); if (hours >= 9 && hours <= 16) { // add code to show button }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM