How to display the date in this format 2015-05-20T14:22:17+00:00 ?
|
1 answer
You can use the predefined DateTime class and its format() method. DateTime::ATOM and DateTime::W3C constants are defined for the format you need (they are equivalent)
<?php $date = new DateTime(); echo $date->format(DateTime::W3C); // 2016-07-30T23:34:11+03:00 If the format specified by a constant for some reason does not fit, you can set the date format yourself
<?php $date = new DateTime(); echo $date->format('Ymd\TH:i:sP'); |
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));) - BOPOH