Database Record Created_at Time Randomly Changes

I'm using OctoberCMS based on Laravel.

I'm using a server with Debian, PHP7, PHP-FPM and APCu.

I have NTP installed and server time set to UTC.

In /etc/php/7.0/fpm/php.ini I have set date.timezone = "UTC".

I have a gallery where you can upload a file.

It saves a record to the database and sets the time uploaded to the created_at column.

$date = date("Y-m-d h:i:s", time());

# Save Database Record
$image = new Gallery();
$image->title = $title;
$image->created_at = $date;

The gallery is arranged by latest image first, using created_at date/time.

Several times now after uploading, the time on the record has been set many hours back.

This makes the gallery images display all out of order.

OctoberCMS database viewer:

database created_at time

When I run date in the terminal, it returns 15:39:24, 3:39 PM.

What could be causing the time to change? And why 3 different conflicting times?



You have a typo in the date format. It should be Y-m-d H:i:s instead of Y-m-d h:i:s

The small h is for 12-hour format of an hour with leading zeros and the capital H is for 24-hour format of an hour with leading zeros