Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format of 2013-04-09T10:00:00Z in php [closed]

Tags:

php

I'm looking for the date() format that will give me a date like this:

2013-04-09T10:00:00Z

Is there something simpler than just using the format 'Y-m-d ...'?

like image 675
amol Avatar asked Dec 04 '22 11:12

amol


1 Answers

The date format 'c' (ISO 8601) used with gmdate() (for UTC time) comes very close:

2013-04-09T10:00:00+00:00

You just need to modify it by replacing the trailing +00:00 with Z (for Zulu):

echo substr_replace(gmdate('c'), 'Z', -6);

The alternative is simply this:

echo gmdate('Y-m-d\TH:i:s\Z');
like image 76
Ja͢ck Avatar answered Dec 09 '22 14:12

Ja͢ck