Ad

Carbon Auto Increments Time By 11 Minutes On Parse

I am using Carbon with Laraveal, my local timezone is in IST. I am passing the below ISO string from the UI.

2019-11-22T03:00:00.000Z

When parsed on the server with the below syntax:

\Carbon\Carbon::parse($value)->timezone($this->user->timezone)->format('Y-m-d H:m:s');

The output I am getting is :

2019-11-22 03:11:00

Don't know why I am getting the additional 11 minutes in the time. UI and Server both runs in my local machine. Don't know what's causing the 11 minutes addition.

Ad

Answer

->format('Y-m-d H:m:s');

should be

->format('Y-m-d H:i:s');

Notice the m for months and i for minutes.

See PHP docs for formats

Ad
source: stackoverflow.com
Ad