DateTime::format and strftime

MultiformeIngegno picture MultiformeIngegno · Jun 4, 2013 · Viewed 10.3k times · Source

I have $date = $run['at']; which gives me 2013-06-03T16:52:24Z (from a JSON input). To transform it to get for example "d M Y, H:i" I use

$date = new DateTime($run['at']);
echo $date->format('d M Y, H:i');

Problem is I need the date in italian. And the only function that supports set_locale is strftime. How can I "wrap" DateTime::format with strftime (or replace, dunno)?

Answer

MultiformeIngegno picture MultiformeIngegno · Jun 4, 2013
setlocale(LC_TIME, 'it_IT.UTF-8');
$date = new DateTime($run['at']);
strftime("%d %B", $date->getTimestamp())

... worked. :)