How to get timestamp in ISO 8601 format with timezone in php

Based on the wix documentation , 2014-04-16T11: 16: 27.930Z is a timestamp in ISO 8601 with a time zone. A brief study shows that the ISO 8601 timestamp displays the time zone with + time_interval (e.g. +00: 00)

I tried the date ('c'), which displays: 2014-04-16T06: 23: 31 + 00: 00

Can someone tell me how to display the timestamp in 2014-04-16T11: 16: 27.930Z and not 2014-04-16T06: 23: 31 + 00: 00 >

+6
source share
1 answer

Considering the Wikipedia article on ISO_8601 , the UTC Offset can be defined as Hour: Minutes Definition as the definition of HoursMinutes.

Z is the zone designation for the UTC zero offset. “09:30 UTC” is therefore represented as “09: 30Z” or “0930Z”. “14:45:15 UTC” will be “14: 45: 15Z” or “144515Z”.

The PHP date method defines the Z parameter as

Z Timezone offset in seconds. The offset for time zones west of UTC is always negative, and for the east of UTC it is always positive.

So, suppose the offset mentioned in the wikipedia article is in seconds, you can create your own ISO 8601 using the date. Example for current server time / date:

 date('Ymd\TH:i:sZ\Z', time()); 
+5
source

All Articles