Reputation: 53
I get the date data as string from Google Analytics like following:
"20190809"
How can I do format with carbon like this:
"2019-08-09"
Upvotes: 1
Views: 609
Reputation: 5149
You can use Carbon::createFromFormat()
to parse a date from an unusual format to a Carbon instance. Then you can format it however you like.
In your case, the following should work:
$date = Carbon::createFromFormat('Ymd','20190809')->format('Y-m-d');
Upvotes: 5