If I have variables like this:
$arivalTime1 = '2020-06-05 15:52:27'
$arivalTime2 = '2020-06-05 15:52:55'
how can I convert these variables using Carbon to have the seconds displayed as 00:
$converted1 = 2020-06-05 15:52:00
$converted2 = 2020-06-05 15:52:00
there is many ways to do it:
1- like Vladimir verleg 's answer:
$arivalTime1 = '2020-06-05 15:52:27'
Carbon::parse($arivalTime1)->format('Y-m-d H:i:00');
2- using startOfMinute() method:
Carbon::parse($time)->startOfMinute()->toDateTimeString();
3- using create method witch gave you more control:
$value=Carbon::parse($time);
$wantedValue=Carbon::create($value->year,$value->month,$value->day,$value->hour,$value->minute,0);
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