I'm currently trying to display a 'time' entry from my database in PHP, and for some strange reason, it's displaying the time + 1 minute.
The entry is
'09:00:00'
And when my PHP code
$schedule = DB::table('event_sessions')->get();
foreach $schedule as $session {
echo date( 'g:m A', strtotime($session->start_time)
}
it is displaying as
9:01 AM
Is there some configuration that might be wrong? I am using the Laravel framework and MySQL.
Because m
is for the month in the date()
function! (So if you want to use Minutes use i
(e.g. echo date( 'g:i A', strtotime("09:34"));
-> 09:34 AM
))
You also can do this:
echo date( 'g:m A', strtotime("09:34"));
And the return is:
09:01 AM
See the manual here for the date()
function: http://php.net/manual/en/function.date.php
An a quote from the manual:
m Numeric representation of a month, with leading zeros 01 through 12
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