如何根据国家/地区更改日期格式 [英] How to change Date format according to the country

查看:128
本文介绍了如何根据国家/地区更改日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据用户所在的国家/地区更改DD/MM/YYYY标签的顺序.

I have a requirement to change the order of DD/MM/YYYY tags according to a users country .

http://en.wikipedia.org/wiki/Date_format_by_country

我想到的方法是创建一个国家/日期格式表,并根据国家/地区选择使用jquery移动字段.

The way that I was thinking to do this is to create a country / Dateformat table and according to the country selection to move the fields around using jquery .

是否存在使用php甚至js或更好的方法来完成此操作的方法? 我也在寻找一张国家/日期格式的表格,而不是手动插入所有值,但是我什么也找不到...

Is there an existing way for this to be done in php or even in js or a better approach ? I was also looking for a table of country/ dateformat rather than inserting all the values manually but I couldn't find anything ...

推荐答案

对于PHP,这应该是一个不错的开始: http://php.net/manual/en/function.setlocale.php

For PHP, this should be a good start: http://php.net/manual/en/function.setlocale.php

对于JavaScript:

For JavaScript: Display date/time in user's locale format and time offset

总而言之,大多数现代语言都很好地内置了语言环境支持.您不必自己实施此操作.这会很累又很麻烦(本地化很困难).

All in all, most modern languages have locale support built-in very well. You should not have to implement this yourself. It will be tiresome and buggy (localization is hard).

这篇关于如何根据国家/地区更改日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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