How do you put a date in a given format?
How to set a date in such a format
Use the predetermined class
DateTimeand its method
format()♪ Constants are defined for the format you need.
DateTime::W3C(they are equivalent)
<?php $date = new DateTime(); echo $date->format(DateTime::W3C); // 2016-07-30T23:34:11+03:00
If the format specified by the constant for some reason is not appropriate, the format of the date may be presented on its own.
<?php $date = new DateTime(); echo $date->format('Y-m-d\TH:i:sP');