[英]get server date and time through hidden field
<TD> <Li id="ll" >
<label class="description" for="element_10">Mobile No </label>
<div>
<input type="hidden" size="15" value= />
</div>
</Li></TD>
How can I get the system date and time through the hidden field and to insert into a MySQL database? 如何通过隐藏字段获取系统日期和时间并将其插入MySQL数据库?
Try this 尝试这个
$todayDate = date("Y-m-d g:i a");// current date
$currentTime = time($todayDate); //Change date into time
$entrytime=date("Y-m-d H:i:s",$currentTime);
<TD> <Li id="ll" >
<label class="description" for="element_10">Mobile No </label>
<div>
<input type="hidden" size="15" name="date" value="<?=$entrytime?>" />
</div>
</Li></TD>
Do you use php? 你用php吗? if so
如果是这样的话
<input type="hidden" size="15" name="date" value=<?=date('Y-m-d H:i:s');?> />
and then after Form posted or you can use ajax you can get the value like this; 然后在表单发布后,或者您可以使用ajax,您可以得到像这样的值;
<?php $date=$_REQUEST['date']; ?>
And then you should Insert to your mysql table and this is like this 然后您应该插入到mysql表中,就像这样
$mysqli->query("INSERT INTO date_table(date) VALUES($date)");
ok now you inserted it. 好的,现在您将其插入。 I Hope this gives you an idea.
我希望这能给您一个想法。
I suggest that you insert NOW()
to database: 我建议您将
NOW()
插入数据库:
INSERT INTO date_table(date) VALUES('NOW()')
If you consist post the time to server by a hidden field: 如果您要通过隐藏字段将时间发布到服务器:
<input type="hidden" size="15" name="date" value="<?php echo date('Y-m-d H:i:s');?>" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.