這是我的PHP代碼。如何設置在php的時間
我想添加我添加日期的時間,但我需要如何知道如何在此腳本中添加時間。
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<form action="index.php" method="get">
From : <input type="text" name="d1" class="tcal" value="" />
<input type="submit" value="Search">
</form>
<table id="resultTable" data-responsive="table" style="text-align: left; width: 400px;" border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<th> Birtday </th>
<th> Name </th>
<th> Gender </th>
</tr>
</thead>
<tbody>
<?php
include('connect.php');
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1="0000-00-00"; };
$result = $db->prepare("SELECT * FROM birthday WHERE date = :a");
$result->bindParam(':a', $d1);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['gender']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
這裏是代碼,我想添加時間如何?
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1=date('Y-m-d')$d1=time('H:i:s'); };
我可以知道我應該怎麼做才能在腳本中添加時間?
$ D1 =日期(「Y -m-d H:i:s「) – aseferov
['time'](http://www.php.net/time)不帶任何參數。 – putvande
+1感謝告訴我 – Umi