Carbon parse to ISO8601

Carbon::now()->toISOString()

this will return "2020-05-12T13:13:42.817684Z"

Carbon::now()->toIso8601String()

this will return "2020-05-12T13:15:32+00:00"

using corePHP

date(DateTime::ATOM, time())

this will return "2021-08-22T15:26:48+10:00"


There is no single 8601 format. 8601 defines various acceptable formats, of which PHP's c represents one of the most common forms.

There is no single character for the specific 8601 format you wish but a format of Ymd\THis\Z should work. T and Zare literal, so escape them with a backslash to avoid them being interpreted in the format string. Be sure that only UTC timestamps are used with this particular format.

http://php.net/manual/en/function.date.php lists all the acceptable format characters.


echo Carbon::now()->toIso8601String();