I want to create a booking script and I can’t solve the problem.
There is a form field for the date, I output the available time slots separately from the database. I want the selected time to appear in the datetime-local field when choosing a timeenter image description here
<div class="form-group">
<label for="date_sched" class="control-label">Appointment</label>
<input type="datetime-local" class="form-control" name="date_sched" value="" required>
</div>
<?
$sched_set_qry = $conn->query("SELECT * FROM `schedule_settings`");
$sched_set = array_column($sched_set_qry->fetch_all(MYSQLI_ASSOC),'meta_value','meta_field');
$a = date("Y-m-d ") . explode(',',$sched_set['morning_schedule'])[0];
$b = date("Y-m-d ") . explode(',',$sched_set['morning_schedule'])[1];
$period =new DatePeriod (
new DateTime($a),
new DateInterval ('PT1H'),
new DateTime ($b)
);
foreach ($period as $date){?>
<input type="button" class="form-control" name="time" value="<? echo $date->format("H:in")?>" >
<? }
?>