我正在学习 PHP,并且有一段查询数据库的 PHP 代码。我获得了一个已经在数据库中的日期,并且想知道这段代码format('dd-mm-yyyy');
是否可以将数据从默认的 'YYYY-MM-DD' 格式化为 'DD-MM-YYYY' 以及如何使用该代码?
<?php
$rfp = $_GET['cid'];
// Connects to Database
mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$data = mysql_query("SELECT rfp_id, issue_date, rfp_status.status FROM company, rfp, rfp_status WHERE company.company_id = rfp.company_id AND rfp_status.status_id = rfp.status_id AND company.company_id = '$rfp'")
or die(mysql_error());
echo "<table border=1px cellpadding=15 bordercolor='#0000CC'>";
#echo "<table border=0 cellpadding=15 bordercolor='#0000CC'>";
echo "<tr align = center bgcolor=white>
<td><b>RFP ID</b></td><td><b>Date Added</b></td><td><b>Status</b></td>" ;
while($row = mysql_fetch_array($data)){
$rid = $row['rfp_id'];
$idate = $row['issue_date'];
$status = $row['status'];
# inserts value into table as a hyperlink
echo "<tr align = center bgcolor=white><td>$rid</td><td><b><a target='_blank' href=view_section_detail.php?rid=$rid>$idate</a></b></td><td>$status</td>";
}
# displays table
print '</table>';
?>
任何帮助,将不胜感激
谢谢