[英]How to show button only the time between 9am to 5pm in react js or javascript?
Let's say I have a button that should display only on the particular time period(9am to 5pm), otherwise the button should not display.假设我有一个按钮应该只在特定时间段(上午 9 点到下午 5 点)显示,否则按钮不应该显示。
The if
statement is only entered if the time is between 9:00 and 17:00 (5pm).仅当时间在 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.