不正确的整数值:'created_on'列的'time()'[关闭]

问题描述 投票:-2回答:2

我试图以时间戳格式检索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列中,我希望以时间戳格式获得当前日期和时间的值。帮助将不胜感激。

php mysql codeigniter
2个回答
1
投票

你可以尝试:

$this->db->set('created_on', time(), false);

对于带有时间戳的字段,将它们从数据数组中删除。


0
投票

你可以试试这个

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'
);
© www.soinside.com 2019 - 2024. All rights reserved.