开发者

date time problem with codeigniter 2

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜