Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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"
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.
Carbon::createFromFormat()
In your case, the following should work:
$date = Carbon::createFromFormat('Ymd','20190809')->format('Y-m-d');
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.