andreyo andreyo - 1 year ago 79
PHP Question

PHP display today date and convert locale to italian

I got a string that must to display today date and set locale to it-IT

$today= date("d m y");
setlocale(LC_TIME, "it_IT.utf8");
print ucwords(strftime("%a %d %B %Y", strtotime($today)));


Got an error, the string is correctly translated to Italian, but print 01 Jan 1970 (01 Gennaio 1970 in italian) so i think got the UNIX timestamp 0.

Thanks

Answer Source

use this:

$today= date("Y-m-d");
setlocale(LC_TIME, "it_IT.utf8");
echo ucwords(strftime("%a %d %B %Y", strtotime($today)));

your fomat date('d m y') can't be recognized by function strtotime(), it returns false