I am making an event calendar. I am currently looking for ways to disable the previous dates on datetime_local
and the minimum date and time is the current. Are there other ways?
<div class="form-group">
<label for="datetime_start" class="control-label">DateTime Start:</label>
<input type="datetime-local" class="form-control" name="datetime_start" id="datetime_start">
</div>
My Answer:
Yes, you can achieve this by using PHP to set the minimum value for the datetime_local input field. Here's an example code snippet:
html
Event Calendar
In this code, we are using PHP's `date` function to get the current date and time in the format required by the datetime-local input field. We then set this as the `min` attribute of the input field, which will disable all past dates and times.
Make sure to adjust the date format in the `date` function to match the format required by the datetime-local input field.
Rate this post
3 of 5 based on 3436 votesComments