PHP day of week numeric to day of week text not English

落爺英雄遲暮 提交于 2019-12-04 19:36:11

nl_NL is a typical Unix style locale name. On Windows, locales follow a different format. You want "nld", "holland", or "netherlands".

Additionally, date() is not locale-aware. You probably want strftime().

You should consider using the extension intl which has IntlDateFormatter.

From the documentation:

$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo "First Formatted output is ".$fmt->format(0);
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo "Second Formatted output is ".$fmt->format(0);

which output

First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00

date does not format dates according to locale. strftime does.

setlocale(LC_ALL, 'german');
echo (iconv('ISO-8859-2', 'UTF-8', strftime('%Y. %B %d. (%A)', mktime('0', '0', '0', '6', '18', '2010'))));

setlocale(LC_ALL, 'hungarian');
echo (iconv('ISO-8859-2', 'UTF-8', strftime('%Y. %B %d. (%A)', mktime('0', '0', '0', '6', '18', '2010'))));

You can use strftime for local date:

setlocale(LC_TIME, 'it_IT');
$timestamp = strtotime("31-12-2012");
echo strftime("%A", $timestamp);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!