Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime::format and strftime

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)?

like image 286
MultiformeIngegno Avatar asked Nov 30 '22 21:11

MultiformeIngegno


1 Answers

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

... worked. :)

like image 152
MultiformeIngegno Avatar answered Dec 04 '22 03:12

MultiformeIngegno