Save date and time through two inputs HI,
I have table
$table->dateTime('dateStart');
}
and I need save date and Time comes from two inputs to one column.
<input type="date" name="dateStart" placeholder="Krátky popis" class="form-control input-sm" required>
<input type="time" name="dateStart" placeholder="Krátky popis" class="form-control input-sm" required>
I am tray something like this.
$event->update([
'dateStart' => $request->input('timeStart')->format('H:i:s')
]);
but not eorking.
Use input type="datetime-local" only in the extreme case.
Its possible to do?
Thx a lot.
Gabriel
You cannot have two form inputs with the same name;
<input type="date" name="dateStart" placeholder="Krátky popis" class="form-control input-sm" required>
<input type="time" name="dateStart" placeholder="Krátky popis" class="form-control input-sm" required>
The second will override the first.
If you need separate fields, call them something different then concatenate them together and pass to the Carbon parse function to create a carbon object.
Also note that type="date" is not supported in Firefox, or Internet Explorer 11 and earlier versions.
... call them something different then concatenate them together and pass to the Carbon parse function to create a carbon object.
How?
<input type="date" name="dateStart" placeholder="Krátky popis" class="form-control input-sm" required>
<input type="time" name="timeStart" placeholder="Krátky popis" class="form-control input-sm" required>
controller
$event->update([
'dateStart' => $request->dateStart . ' ' . $request->timeStart .':00';
]);
Yes, beautiful.
Thx a lot.
Please sign in or create an account to participate in this conversation.