@RiggsFolly is correct, the input time from the database is irrelevant because the date()
function is to convert the string to date + format the output.
Let's say the current time is 7:30 pm (night)
Using h:i A (doesn't work ✘)
PHP echo
Because you specified AM
it is showing the AM in the output
$t = date('h:i A');
echo $t;
// output: 7:30 pm
HTML date
input
The same AM
will not work inside the date input
<input type="time" value="<?php echo date('h:i A') ?>">
<!-- output: --:-- -- -->
Using h:i (doesn't work ✘)
PHP echo
How about we use without AM
or PM
. just plain time not provide the AM
PM
. Probably if you are following 24hrs format then you can consider this as AM
$t = date('h:i');
echo $t;
// 7:30
HTML date
input
<input type="time" value="<?php echo date('h:i') ?>">
<!-- output: 07:30 AM (the AM and PM doesn't work here, the reason why it displays AM is because that is the first thing in the date dropdown list) -->
H:i (works ✔)
PHP echo
You can try the H
. This is for 24hr format.
$t = date('H:i');
echo $t;
// 19:30
HTML date
input
No need to specify the A
, since it is 24hrs format, the input automatically detects and displays the correct time.
<input type="time" value="<?php echo date('H:i') ?>">
<!-- output: 7:30 pm -->
Here's a simple explanation: https://stackoverflow.com/a/51515814/5413283