开发者

date time problem with codeigniter 2

开发者 https://www.devze.com 2023-02-13 08:04 出处:网络
I have set mysqldatabase field type as \'datetime\' when i send $now = time(); echo form_hidden(\'a_date\', unix_to_human($now));

I have set mysql database field type as 'datetime'

when i send

$now = time();
echo form_hidden('a_date', unix_to_human($now));

from views all I get in database is开发者_如何学C 0000-00-00 00:00:00

please help


i usually do it like this

$now = date('Y-m-d H:i:s', strtotime('now'));
echo form_hidden('a_date', $now);

If you want to output differently, use http://www.php.net/manual/en/function.date.php

Also, if you want to record the time and not update it, I would recommend a timestamp field instead of datetime field. That way, you don't have to pass the db anything

0

精彩评论

暂无评论...
验证码 换一张
取 消