以mysql datetime格式转换法语格式的日期 [英] Convert a date in french format in a mysql datetime format
问题描述
我想以日期时间格式(2011-11-08 06:00)转换法国格式的日期(08 novembre 2011à06h00)。
我可以用法术格式日期转换一个日期时间:
函数dateFR($ datetime){
setlocale(LC_ALL,'fr_FR');
return strftime('%d%B%Y& agrave;%Hh%M',strtotime($ datetime));
}
但我不知道如何做相反的事情。
感谢您的帮助。
怎么样?
date(Y-m-d H:i:s,strtotime($ datetime));
啊,是的,我看到问题。 strtotime
仅转换英文文本(强调我的):
该函数希望是给出一个包含英文日期格式的字符串,并尝试将该格式解析为Unix时间戳记
您的最好的赌注可能是您的特定格式的 preg_match
,因为似乎没有任何特定于区域的功能将转换像月份名称。 p>
I'd like to convert a date in french format (08 novembre 2011 à 06h00) in a datetime format (2011-11-08 06:00).
I'm able to convert a datetime in french format date with a little function:
function dateFR($datetime) {
setlocale(LC_ALL, 'fr_FR');
return strftime('%d %B %Y à %Hh%M', strtotime($datetime));
}
But I don't know how to do the opposite.
Thank you for your help.
How about?
date("Y-m-d H:i:s", strtotime($datetime));
Ah, yes, I see the problem. strtotime
only converts english text (emphasis mine):
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp
Your best bet is probably going to be preg_match
for your specific format, as there doesn't seem to be any locale-specific functions that will convert things like the month name.
这篇关于以mysql datetime格式转换法语格式的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!