我试图以时间戳格式检索codeigniter中的当前时间和日期。以下是几行代码。
$data = array(
'username' => $username,
'password' => $password,
'email' => $email,
'ip_address' => $ip_address,
'created_on' => time(),
'date_created' => time(),
'active' => '1',
'user_type_id' => '2'
);
这里,在created_on列中,我希望以时间戳格式获得当前日期和时间的值。帮助将不胜感激。
你可以尝试:
$this->db->set('created_on', time(), false);
对于带有时间戳的字段,将它们从数据数组中删除。
你可以试试这个
date("Y-m-d"); // this will show the data in the format year-month-day
date("H:i:s"); // this will show the data in the format 14:36:55
$data = array(
'username' => $username,
'password' => $password,
'email' => $email,
'ip_address' => $ip_address,
'created_on' => date("H:i:s"),
'date_created' => date("Y-m-d"),
'active' => '1',
'user_type_id' => '2'
);