我需要将孟加拉语日期转换为标准英语日期格式。我的手镯日期:
$banglaDate = '৩১ ডিসেম্বর, ২০১৪ ইং ১০:৫৭ মিঃ';
我需要将此手镯日期转换为标准英语日期(2014-12-31 10:57
)
答案 0 :(得分:12)
您可以使用以下步骤:
<?PHP
$banglaDate = '৩১ ডিসেম্বর, ২০১৪ ইং ১০:৫৭ মিঃ';
$search_array= array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০", "জানুয়ারী", "ফেব্রুয়ারী", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগষ্ট", "সেপ্টেম্বার", "অক্টোবার", "নভেম্বার", "ডিসেম্বার", ":", ",");
$replace_array= array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ":", ",");
// convert all bangle char to English char
$en_number = str_replace($search_array, $replace_array, $banglaDate);
// remove unwanted char
$end_date = preg_replace('/[^A-Za-z0-9:\-]/', ' ', $en_number);
// convert date
$bangla_date = date("Y-m-d H:i ", strtotime($end_date));
// output : 2014-12-31 10:57
?>