Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Bangla date to standard English date

Tags:

date

php

I need to convert Bangla Date to standard English date format. My bangle date :

$banglaDate = '৩১ ডিসেম্বর, ২০১৪ ইং ১০:৫৭ মিঃ';

And I need to convert this bangle date to standard English date ( 2014-12-31 10:57 )

like image 507
user2013 Avatar asked Dec 31 '14 06:12

user2013


People also ask

What is the date of Bengali today?

Today is Monday, August 22, 2022 and Bengali date is Bhadro 5, 1429 Bangabda (সোমবার, ০৫ ভাদ্র, 1429 বঙ্গাব্দ).

Which Bengali year is this?

The Bengali New Year, also known as Poila Boishakh (Pohela Boishakh), is decided according to the lunisolar calendar, which is entering this year in 1429. Poila Boishakh 1429 will be observed on 15 April 2022 as per the lunisolar calendar.


1 Answers

You can use the following step :

<?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
?>
like image 97
sabbir Avatar answered Sep 30 '22 10:09

sabbir