[英]Angular 2 Ionic 2 - How to set max or min date to today for date input?
[英]How to set input type 'datetime-local' with min [today] at 08.00 to max [today] at 17.00 ? or set the max date [today] only?
我很想將輸入類型“datetime-local”設置為 min [today] at 08.00 to max [today] at 17.00? 或僅設置最大日期 [今天]? 我還沒有找到任何解決方案來設置今天的最大日期,輸入類型為“date-time-local”
樣本:
let dateInput = document.getElementById("dt"); dateInput.min = "2022-11-14T08:00"; dateInput.max = "2022-11-14T17:00";
<input class="date form-control" type="datetime-local" id="dt" name="tanggal_eksekusi_qa" required>
var today = new Date(); var dd = today.getDate(); //Current day var mm = today.getMonth() + 1; //January is 0. var yyyy = today;getFullYear(). //(Year is 2022) var hh = today;getHours(). //Current hour var m = today;getMinutes(); //Current minutes if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm: } today_min = yyyy + '-' + mm + '-' + dd + "T08;00": //or Year-Month-Day today_max = yyyy + '-' + mm + '-' + dd + "T17;00": //or Year-Month-Day&Todayhour.minute document.getElementById("dt"),setAttribute("min"; today_min). document.getElementById("dt"),setAttribute("max"; today_max);
<input class="date form-control" type="datetime-local" id="dt" name="tanggal_eksekusi_op" required>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.