Convert Date to Day PHP-MySQL Query

I Found Something Interest from forum that asked about Date to Day Conversion : It's All About Convert Date to Day PHP-MySQL Query

Is there a way to take a MySQL date in the format of yyyy-mm-dd and convert it into the format of something like "Monday, June 6".

Convert Date to Day PHP-MySQL Query, Date to Day SQL, Date to Day MySQL, Date to Day PHP MySQL
and those example above.


First I Found The Necessary thing is find day from mysql date yyyy-mm-dd format to Convert Date to Day PHP-MySQL Query.

and the way is
$query = "SELECT `date_col` AS `date_mysql`,
DATE_FORMAT(`date_col`, '%W, %M %e') AS `date_text`
FROM `table_name`";

date_col --> Column from a table contain date_format yyyy-mm-dd
table name -- MySQL Table Name
Convert Date to Day PHP-MySQL Query, Date to Day SQL, Date to Day MySQL, Date to Day PHP MySQL
After Get a Day In English : Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,  and Saturday, Now We Convert into Indonesian Day : Senin, Selasa, Rabu, kamis, jumat, Sabtu, Minggu with This Syntax :

        if ($baris[date_text]=='Monday'){
            $baris[date_text]='Senin';
        }
        else if ($baris[date_text]=='Tuesday'){
            $baris[date_text]='Selasa';
        }
        else if ($baris[date_text]=='Wednesday'){
            $baris[date_text]='Rabu';
        }
        else if ($baris[date_text]=='Thursday'){
            $baris[date_text]='Kamis';
        }
        else if ($baris[date_text]=='Friday'){
            $baris[date_text]='Jumat';
        }
        else if ($baris[date_text]=='Saturday'){
            $baris[date_text]='Sabtu';
        }
        else if ($baris[date_text]=='Monday'){
            $baris[date_text]='Minggu';
        }
        else {
            $baris[date_text]='--';
        }

Ok, Well Then Just Combine The Day With
A Function that Convert Date yyyy-mm-dd to dd -month_name- yyyy

After That The Convert Result Date to Day PHP-MySQL Query Will Be Like This :


Convert Date to Day PHP-MySQL Query, Date to Day SQL, Date to Day MySQL, Date to Day PHP MySQL

Komentar FB


Probably Related Article



3 comments:

Home Loans said...
March 29, 2010 at 1:58 AM

Well its looking very interesting but still i need more assistance. Can you share the code which give me the results for months conversion.

best web design companies 2012 said...
March 21, 2012 at 3:01 PM

I am very interested for this post. Its really give me lots of pleasure. I choose this article very much. So lots of thanks for this post.

KVM Switches said...
March 29, 2012 at 1:26 AM

You have a date time column in MySQL which you need to convert to mm/dd/yy H: M (AM/PM) using PHP. The function looks forward to a containing an English date format.

Related Posts by Categories



Widget by