以mysql日期时间格式转换法语格式的日期

Ben*_*eno 5 php datetime date

我想以日期格式(2011-11-08 06:00)转换法语格式的日期(08年11月11日至06:00).

我能用一个小函数转换法语格式日期的日期时间:

function dateFR($datetime) {
    setlocale(LC_ALL, 'fr_FR');
    return strftime('%d %B %Y à %Hh%M', strtotime($datetime));
}
Run Code Online (Sandbox Code Playgroud)

但我不知道如何做相反的事情.

谢谢您的帮助.

DTe*_*est 5

怎么样?

date("Y-m-d H:i:s", strtotime($datetime));
Run Code Online (Sandbox Code Playgroud)

啊,是的,我看到了问题.strtotime只转换英文文本(强调我的):

该函数期望给出一个包含英文日期格式的字符串,并尝试将该格式解析为Unix时间戳

您最好的选择可能是preg_match针对您的特定格式,因为似乎没有任何特定于语言环境的功能可以转换月份名称之类的内容.