I have an issue with inserting current datetime to custom wordpress datetime column. I've used curent_time
function I also used date('Y-m-d H:m:s')
as value for the column but it did not work.
I will provide my code for any suggestions:
global $wpdb;
$load_rec_table = $wpdb->prefix.'load_rec';
// Insert into load record table
$wpdb->insert($load_rec_table,array(
'rec_date' => current_time('mysql'),
'total_load' => $_POST['totalPower'],
'total_gap' => $_POST['totalGap'],
'carriage' => $_POST['carriage']
));
You can use NOW() or CURRENT_TIMESTAMP() functions of Mysql
global $wpdb;
$load_rec_table = $wpdb->prefix.'load_rec';
// Insert into load record table
$wpdb->insert($load_rec_table,array(
'rec_date' => NOW(),
'total_load' => $_POST['totalPower'],
'total_gap' => $_POST['totalGap'],
'carriage' => $_POST['carriage']
));