While Developing applications in
Laravel, there comes situations where you have date in simple string format. For instance getting raw response from an
API. But you want to convert that string into Carbon instance and use the
Carbon helpers on it. Well there’s a simple solution to it.
$date = Carbon\Carbon::parse($rawDate);
well thats it. You’ll now have a
Carbon instance & you can format the date as you like using
Carbon helper functions. For instance.
If you’ve any questions in mind, leave us a comment below. Do follow us on Twitter.