iso timestamp code example

Example 1: iso date

2021-01-05T11:48Z

Example 2: iso-8601

echo date('c'); //2021-02-03T21:42:51-08:00

echo date(DATE_ISO8601); //2021-02-03T21:42:51-0800

$datetime = new DateTime();
echo $datetime->format(DateTime::ATOM); //2021-02-03T21:42:51-08:00

Example 3: Datetime to utc format

string foo = yourDateTime.ToUniversalTime()
                         .ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");

Example 4: iso timestamp

# With Timezone
"2019-09-07T15:50-04:00"
# Without Timezone
"2019-09-07T15:50+00Z"

Tags:

Misc Example