如何使用PHP中的HTML表单获取当前时间
答
正如例如,你可以尝试在
<?php
if($_REQUEST['submit'])
{
echo "Today is " . date("Y/m/d") . "<br>"; // Today is 2016/11/26
echo "Time is" . date("h:i:sa"); // prints the time
?>
<!-- To display time in textarea you can use the following code -->
<textarea><?php echo date("h:i:sa"); ?></textarea>
<?php } ?>
<form action="" method="get">
<textarea><?php echo date("h:i:sa"); ?></textarea>
<input type="submit" name="submit" value="Show Time" />
</form>
下面的代码和有关时间的详细信息请注意,您应该保存文件,扩展名为.php
如果你想只提交后几秒钟显示小时,你可以这样做。如果($ _ REQUEST){echo_data('d-m-Y H:i'); } –
[如何获取当前日期和时间在PHP?]可能重复(http://stackoverflow.com/questions/470617/how-to-get-the-current-date-and-time-in-php ) –