嗨,我的区域格式日期是: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
有做这个东西的功能吗?
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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句