Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carbon parse to ISO8601

I am trying to get the current time and format it like:

"2018-09-26T21:40:29+02:00"

But when I try:

$isoDate = \Carbon\Carbon::now()->format('c');

as I understood passing a c to format function will parse it to iso8601 but clearly thats not the case.

Any help on how to parse current time to ISO8601 OR 20181001T094006Z

like image 753
Aladin Small Avatar asked Sep 26 '18 19:09

Aladin Small


People also ask

What is Z in iso8601?

Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "T0930Z". "14:45:15 UTC" would be "14:45:15Z" or "T144515Z". The Z suffix in the ISO 8601 time representation is sometimes referred to as "Zulu time" because the same letter is used to designate the Zulu time zone.

What is carbon :: now ()?

Carbon::now returns the current date and time and Carbon:today returns the current date.

How do you convert DateTime to date in carbon?

$date = Carbon\Carbon::createFromFormat('d/m/Y', '11/06/1990');

What is the difference between toISOString and toUTCString?

toISOString() provides millisecond values, whereas . toUTCString() does not.


1 Answers

echo Carbon::now()->toIso8601String();
like image 190
Nurdin Aidanov Avatar answered Oct 07 '22 01:10

Nurdin Aidanov