How to display a date as iso 8601 format with PHP

You can use the date() function in PHP to display a date in ISO 8601 format. The format string for ISO 8601 is Y-m-d\TH:i:sO. Here is an example of how to use it:

<?php

$date = new DateTime();
echo $date->format('Y-m-d\TH:i:sO');

Watch a course Learn object oriented PHP

This will output the current date and time in the ISO 8601 format, for example: "2022-09-22T14:44:11+00:00"