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".
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
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 :
Tidak ada komentar:
Posting Komentar