DateTime :: format和strftime [英] DateTime::format and strftime

查看:192
本文介绍了DateTime :: format和strftime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 $ date = $ run ['at']; 这给了我 2013-06-03T16:52:24Z 一个JSON输入)。
要转换为例如 d MY,H:我我使用

I have $date = $run['at']; which gives me 2013-06-03T16:52:24Z (from a JSON input). To transform it to get for example "d M Y, H:i" I use

$date = new DateTime($run['at']);
echo $date->format('d M Y, H:i');

问题是我需要意大利语的日期。而支持 set_locale 的唯一功能是 strftime
如何使用 strftime (或替换,dunno)包装 DateTime :: format / p>

Problem is I need the date in italian. And the only function that supports set_locale is strftime. How can I "wrap" DateTime::format with strftime (or replace, dunno)?

推荐答案

setlocale(LC_TIME, 'it_IT.UTF-8');
$date = new DateTime($run['at']);
strftime("%d %B", $date->getTimestamp())

...工作:)

这篇关于DateTime :: format和strftime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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