根据PHP中的区域设置获取日期格式 [英] Get date format according to the locale in PHP

查看:116
本文介绍了根据PHP中的区域设置获取日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个非常简单的问题。我有一个区域设置标识符en,en_US,cs_CZ或其他。我只需要获取该区域设置的日期时间格式。我知道我可以根据语言环境轻松地格式化任何时间戳记或日期对象。但是,我只需要日期格式的字符串表示,我们假设一个正则表达式。是否有管理此功能的功能?我没有找到任何目标...

There is a very simple problem. I have a locale identifier, en, en_US, cs_CZ or whatever. I just need to get the date-time format for that locale. I know I can easily format any timestamp or date object according to the locale. But I need just the string representation of the date format, let's say a regular expression. Is there any function managing this functionality? I haven't found any so far...

Exapmle:

$locale = "en_US";
$format = the_function_i_need($locale);
echo $format; // prints something like "month/day/year, hour:minute"


推荐答案

从注释转换:

您将必须构建一个包含可能性列表的数组。

you will have to build an array with a list of the possibilities.

http://en.wikipedia.org/维基/ Date_format_by_country 应该有帮助。

在完成后将功能发布到某个地方,我相信它会派上用场的人。

post the function somewhere when done, i'm sure it would come in handy for others

这篇关于根据PHP中的区域设置获取日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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