0

So I'm making a reservations form, and I'll store all the data including the date in the database, but I don't want the certain dates to show if certain time has pass today, (example 12:00 CET), or if the date is unavaliable, either due to date from database-tbl_unavaliable or due to reaching max amnout of reservations for the day (10 for example). So far after a few hours of searching I've found only this on SO, I don't know if the thing i want is doable or not with php since it's kind of the only thing I currently somewhat know and I'm still currently learning it. I do not know anything of JavaScript. But is there a kind of way to maybe get a $variable with php and make that a condition in JavaScript or something similar?

<script>
function getISODate(){
  var d = new Date();
  return d.getFullYear() + '-' + 
          ('0' + (d.getMonth()+1)).slice(-2) + '-' +
          ('0' + d.getDate()).slice(-2);
}

window.onload = function() {
  document.getElementById('minToday').setAttribute('min',getISODate());
}
</script>

<p>Select date(must be on or after today)<input type="date" id="minToday"></p>

  • You can disable it directly from php when a certain condition is met, like ` id="minToday">` where `$condition` is whatever condition you were mentioning. – Federico klez Culloca Dec 02 '21 at 10:37
  • @FedericoklezCulloca My mistake for asking the question wrong, corrected myself right now. I need the certain dates in calendar not to be pickable or not to show, example, if 3pm passes on todays date, today's date is not pickable anymore. Also if i put a date in database tbl_unavaliable(basically picking non working days) let's say i pick christmas now for example, then 25.12.2021 won't be pickable. Even if it's 23 days in foward. –  Dec 02 '21 at 10:49
  • 1
    I don't think that's possible with the standard `input` element. See [this other question](https://stackoverflow.com/questions/47032326/how-can-i-disable-particular-date-of-input-type-date-from-javascript) for some ideas on how you could implement what you need in another way. – Federico klez Culloca Dec 02 '21 at 10:57
  • Ah, ignore my previous comments, I misunderstood again apparently. I thought you were talking about specific dates, not a range of dates. – Federico klez Culloca Dec 02 '21 at 11:05

0 Answers0