Jumat, 19 Maret 2010

Convert MySQL date Format to Indonesian Date Format with PHP

Below is A PHP Function to Convert MySQL date Format to Indonesian Date Format.

Example : 2010-10-10 can be 10 Oktober 2010

Below  is the Function to Convert MySQL date Format to Indonesian Date Format with PHP
javascript:void(0)

    function waktuindo($datawaktu)
    {
        $waktu=explode('-',$datawaktu);
        if ($waktu[1] == '01')  //jika 01 maka januari
            {
                $bulan='Januari';
            }
        elseif ($waktu[1] == '02')  
            {
                $bulan='Februari';
            }
        elseif ($waktu[1] == '03')  
            {
                $bulan='Maret';
            }
        elseif ($waktu[1] == '04')  
            {
                $bulan='April';
            }
        elseif ($waktu[1] == '05')  
            {
                $bulan='Mei';
            }
        elseif ($waktu[1] == '06')  
            {
                $bulan='Juni';
            }
        elseif ($waktu[1] == '07')  
            {
                $bulan='Juli';
            }
        elseif ($waktu[1] == '08')  
            {
                $bulan='Agustus';
            }
        elseif ($waktu[1] == '09')  
            {
                $bulan='September';
            }
        elseif ($waktu[1] == '10')  
            {
                $bulan='Oktober';
            }
        elseif ($waktu[1] == '11')  
            {
                $bulan='November';
            }
        elseif ($waktu[1] == '12')  
            {
                $bulan='Desember';
            }
        else  
            {
                $bulan='00';
            }
        echo"$waktu[2] $bulan $waktu[0]";
    }

  

It was a simple fuction to Convert MySQL date Format to Indonesian Date Format with PHP by myself Maybe need a correction for perfection.

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

Senin, 01 Maret 2010

Linux User Password Reset

How can we do a Linux User Password Reset? It's a simple way to do User Password Reset in Linux.

1. To reset a User Password Reset, use passwd command. You have to change it to a different password.
2. Open terminal or shell prompt
3. Login as the root user (Only Root User can do User Password Reset)
4. Type the following command to do User Password Reset.
# passwd username
5. For example, reset a sanjaya's password, enter:
# passwd sanjaya
6. Type a new password twice to do User Password Reset.

After you type a new password twice, you have User Password Reset in Linux Successfully.

That's it, a simple way to do User Password Reset in Linux.