I'm getting a time value from a database call in the following format:
HH:MM:SS
Here are some examples:
08:15:00
22:45:00
I need to however convert these and display them, using the above examples, as follows:
8:15 AM
10:45 PM
and so on. I've been playing around with the strtotime options but everything I've tried has failed so far, and I'm not sure if that's the correct function to even use. I need go from to:
$bookingTime = "08:15:00"
to:
$bookingTime = "8:15 AM"
you have to try this one:
echo date("g:i A", strtotime($bookingTime));
You can try something like this as well
$d = new DateTime('08:15:00');
echo $d->format( 'g:i A' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With