从西班牙语 PHP 中的字符串中获取日期
我正在尝试:
setlocale(LC_ALL,"es_ES");
$string = "24/11/2014";
$date = DateTime::createFromFormat("d/m/Y", $string);
echo $date->format("l");
我到了星期一,这是正确的,但我需要西班牙语,那么,有没有办法用西班牙语检索这一天?
And I'm getting Monday, which is correct but I need it in spanish, so, is there any way to retrieve this day in spanish?
推荐答案
从日期时间格式页面:
此方法不使用语言环境.所有输出均为英文.
This method does not use locales. All output is in English.
如果您需要语言环境,请查看 strftime示例:
If you need locales look into strftime Example:
setlocale(LC_ALL,"es_ES");
$string = "24/11/2014";
$date = DateTime::createFromFormat("d/m/Y", $string);
echo strftime("%A",$date->getTimestamp());
相关文章