I have a table with a date column in it, but its data type using a varchar.
Month | 01 02 03
I want to convert that data into a form of month name,I have tried this way, the data is successfully converted into months but always month of january.
foreach($list as $post) {
$time = strtotime($post->album_periode_bulan);
$newformat = date('F',$time);
$no++;
$row = array();
$row[] = $no;
$row[] = $time;
$data[] = $row;
}
I have implemented this in datatables
In MySQL you do
UPDATE your_table
SET your_column = DATE_FORMAT(STR_TO_DATE(your_column, '%m'), '%M');
and that's it. Read more about the format parameters for both functions here .
Note though, newer releases set the sql mode NO_ZERO_IN_DATE
by default. You might need to disable this temporarily with
set session sql_mode = "";
Check this before!!! with
show session variables like 'sql_mode';
or you might end with all your rows being NULL
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.