您好我的:区域格式日期如:01-Iulie-2014或01-Decembrie-2015我希望将其转换为:2014-07-01或2015-12-01。我尝试过类似的东西,但没有结果:
$mydate = date('Y-m-d', strtotime($this->input->post('pay_date')));
但是strtotime会给我 false
有没有这样做的功能?
答案 0 :(得分:0)
strtotime()将任何英文文本日期时间描述解析为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);
答案 1 :(得分:0)
来自http://php.net/manual/en/function.date.php:
要格式化其他语言的日期,您应使用setlocale()和strftime()函数代替date()。