在我的oracle數據庫日期格式就像「13.10.2015 22:25:56」 但這樣做後,選擇我的網站日期格式正在改變像這樣「13-OCT-15」 - 無HH:mm:ss的來自oracle數據庫的日期和時間
<table border='1' align='left' bordercolor='navy' width='13%'>
<tr>
<td align="center">date - number</td>
</tr>
<td align="center">
<?php
$Date_1 = $_POST['Date_1'];
$Date_2 = $_POST['Date_2'];
$conn = oci_connect('login', 'password', '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=port) (CONNECT_DATA=(SERVICE_NAME=service)))');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
//----------------------------------------------------------------------------------
$sql="SELECT DATE, NUMBER FROM DB.RESULT
WHERE (DATE BETWEEN TO_DATE('{$Date_1} 00:00:00', 'YYYY.MM.DD HH24:MI:SS')
AND TO_DATE('{$Date_2} 23:59:59', 'YYYY.MM.DD HH24:MI:SS'))
ORDER BY DATE desc";
$stid = oci_parse($conn, $sql);
oci_execute($stid);
echo "<table border='1' align='left' width='100%' height='100%' bordercolor=navy>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
foreach ($row as $item) {
echo " <td align='center'>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n","</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</td>"; ?>
如果日期欄是日期類型,你應該使用TO_CHAR轉換。 'TO_CHAR(DATE,'dd.mm.yyyy hh24:mi:ss')' – Tatiana