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
精彩评论