[英]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.