以mysql datetime格式转换法语格式的日期 [英] Convert a date in french format in a mysql datetime format

查看:250
本文介绍了以mysql datetime格式转换法语格式的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以日期时间格式(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屋!

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