When working on Laravel there will be a time when you would have to parse a datetime string to a Carbon object for further processing.
Carbon provides a very simple to use method to achieve it for a datetime string of any format. Following is an example –
$start_date = "2019-12-10T15:03:01";
$carbonObject = Carbon::parse($start_date);
//Now print the object to visualise the results
dd($carbonObject);
Here is what you will see in your output –
Carbon\Carbon @1575968581 {#144
date: 2019-12-10 15:03:01.0 Asia/Dhaka (+06:00)
}
If you have any questions, do let us know in the comments below. Thanks!