With a bit of googling you are able to answer your question. Take a look at the PHP documentation: https://www.php.net/manual/en/datetime.format.php
Carbon format date to YYYY-MM-DDThh:mm:ssTZD
I'm really confused. How can I format a created_at value to YYYY-MM-DDThh:mm:ssTZD format?
This is obviously not working
\Carbon\Carbon::parse($created_at)->format('YYYY-MM-DDThh:mm:ssTZD')
Any ideas?
That format doesn’t make any sense, so it’s probably not what you want. As @tykus has pointed out, the literal T between the date and the time needs a backslash to be escaped. Going by the example output you posted in your comment, the format you gave in the question is definitely not what you want.
Given the time 18:08:04 on 12 August 2022 in Paris, the format you give in the question will yield:
2022202220222022-AugAug-FriFriCST0606:0808:0404CST3600Fri
Not really understandable. You want this:
Carbon::parse($created_at)->format('Y-m-d\TH:i:s.vp');
If you don’t absolutely need the milliseconds (Google doesn’t require them), you can also use this Carbon shortcut, which is easier:
Carbon::parse($created_at)->toW3cString();
Please or to participate in this conversation.