如何在PHP中将地区日期转换为标准格式日期


How to convert regional date into normal format date in PHP?

我有我的:区域格式日期,如:01- iuli -2014或01- december -2015,我想将其转换为:2014-07-01或2015-12-01。我试过这样做,但没有结果:

$mydate = date('Y-m-d', strtotime($this->input->post('pay_date')));

但是strtotime返回me false

是否有一个函数来做这些事情?

strtotime()将任何英文文本datetime描述解析为Unix时间戳,因此您可以使用您的语言创建一个包含月份名称及其等效英文月份名称的数组,然后使用strtotime,如:

function custom_strtotime($your_date) { 
    //create month names as your_lang_month_name => english_month_name 
    $months_arr = array('Janvier'=>'jan',...,'Decembrie'=>'dec')
    return strtotime(strtr(strtolower($your_date), $months_arr)); 
}
echo custom_strtotime($some_date);

From http://php.net/manual/en/function.date.php:

要在其他语言中格式化日期,您应该使用setlocale()和strftime()函数来代替date()。