从西班牙语 PHP 中的字符串中获取日期 [英] Get day from string in spanish PHP

查看:25
本文介绍了从西班牙语 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());

这篇关于从西班牙语 PHP 中的字符串中获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆