Trying to limit the start date as tomorrow (local date). Can someone tell why below code isn't working:
<form method="POST">
<div>
<label for="s2">pickup_date</label>
<input type = 'date' name='pickup_date' required>
<br /><br />
</div>
</form>
<script>
var time = new Date();
var localTimeStr = time.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' });
today = new Date(localTimeStr)
tomorrow = new Date(today.setDate(today.getDate() + 1)).toISOString().split('T')[0];
t = String(tomorrow)
document.getElementsByName("pickup_date")[0].setAttribute('min', t);
</script>
the output of below code is 2022-01-18:
var time = new Date();
var localTimeStr = time.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' });
today = new Date(localTimeStr)
tomorrow = new Date(today.setDate(today.getDate() + 1)).toISOString().split('T')[0];
t = tomorrow.split('-')[0]+'-'+tomorrow.split('-')[1]+'-'+tomorrow.split('-')[2]
console.log(t)
however, the calendar start date in the form is still 2022-01-17. But, when I manually set
document.getElementsByName("pickup_date")[0].setAttribute('min', '2022-01-18');
the calendar start from 2022-01-18 correctly. why!