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.
The if
statement is only entered if the time is between 9:00 and 17:00 (5pm).
const date = new Date(); const hours = date.getHours(); if (hours >= 9 && hours <= 16) { // add code to show button }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.