PHP date to string conversion adds a minute to each result

I'm currently trying to display a "time" record from my database in PHP, and for some strange reason, it displays time + 1 minute.

Record

'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 displayed as

9:01 AM

Is there some kind of configuration that might be wrong? I use the Laravel and MySQL framework.

+4
source share
1 answer

Because mfor a month in function date()! (So, if you want to use Minutes, use i(e.g. echo date( 'g:i A', strtotime("09:34"));09:34 AM))

You can also do this:

echo date( 'g:m A', strtotime("09:34"));

And returns:

09:01 AM

date(): http://php.net/manual/en/function.date.php

:

m 01 12

+7

Source: https://habr.com/ru/post/1570360/


All Articles