ISO8601 date format?

I have a year (2002), and I'm trying to make it in the following format:

2002-00-00T00: 00: 00

I tried various iterations, the last of which was the following:

$testdate = DateTime::createFromFormat(DateTime::ISO8601, date("c"))
echo date_format($testdate, '2002'); 

But, even if I get closer, it always seems that he adds +00: 00 to the end ...

+5
source share
2 answers

The c format in PHP always adds the time zone offset. You cannot avoid this. But you yourself can create a date from the components:

date('Y-m-d\TH:i:s', $testdate);
+13
source
date('Y-m-d\TH:i:s\Z', time() - date('Z'));
0
source

All Articles