Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何为输入字段指定默认值“当前日期和时间”_Php_Codeigniter_Codeigniter 2 - Fatal编程技术网

Php 如何为输入字段指定默认值“当前日期和时间”

Php 如何为输入字段指定默认值“当前日期和时间”,php,codeigniter,codeigniter-2,Php,Codeigniter,Codeigniter 2,如何将默认值current time stamp分配给输入字段,然后我想将其作为隐藏项插入db <input name="status" id="status" type="hidden" value="<?php echo CURRENT_TIMESTAMP ?>" /> </td> </tr> 像这样试试 <input type="hidden" value="<?php echo time();?

如何将默认值current time stamp分配给输入字段,然后我想将其作为隐藏项插入db

  <input
    name="status" id="status"
    type="hidden"
    value="<?php echo CURRENT_TIMESTAMP ?>"
  />
</td> </tr>
像这样试试

<input type="hidden" value="<?php echo time();?>" name="my_unique">

您将使用:
time()获取当前时间戳


所以:
对于隐藏字段,可以使用php函数date()



这个输入可以吗

为什么不在数据库中使用日期时间字段并立即存储()插入时,最好使用当前的\u时间戳default@Dave他说他已经有一个带有当前时间的字段,可能是的副本,但他想要当前时间戳,date正在给他带有日期的当前时间。Raheel Shan非常好,你的方法很好,谢谢你的回答。欢迎你。但请在发帖前做一些调查。谷歌搜索的解决方案很容易找到。Gautam感谢我如你所说使用的快速响应,但它在数据库表列(如1363340419)中节省了时间。culumn类型是一个varchar,我甚至使用了时间戳,但结果相同。因此你需要在数据库中指定我们关于时间格式的信息。?对,因为他想在服务器端使用它,也许更明智的做法是使用更简单的格式进行解析(比如时间戳)。
$data['column_name'] = date('Y-m-d H:i:s');
$data['other_column1'] = 'other value 1';
$data['other_column2'] = 'other value 2';
$data['other_column3'] = 'other value 3';

$this->db->insert('tabel_name',$data);
<?php echo date("Y/m/d h:i:s a"); ?>