You can do something like this:
$dateTime = new DateTime($myDate); $formatted = $dateTime->format("Ymd\TH:i:sz\Z");
Specified solution with:
$dateTime->format(DateTime::W3C); $dateTime->format(DateTime::ISO8601);
returns strings like:
2012-11-28T17:21:11+0100
which cannot be analyzed, at least with newer versions of Solr.
I would not use gmdate if you need to support time zones. The implementation of DateTime is well executed and also available for functional programming.
source share