I have this little function allowing me to format a date:
function formatDateTime($date, $lang) {
setlocale(LC_TIME, $lang);
return strftime('%A %e %B %Y', $date);
}
I'm using it like this:
formatDateTime('2016-12-27', 'fr_FR');
The problem I have is the function return me a wrong date in french jeudi 1 janvier 1970
.
It should be Mardi 27 décembre 2016
.
Do you help me to find why ?
Thanks.
strftime
expects a UNIX timestamp, not a date string.http://php.net/manual/en/function.strftime.php
You can either put in a UNIX timestamp as returned by
time()
or convert the input to a timestamp:See also: http://php.net/datetime