因此,我對我的公司很陌生,我有我們以前的開發人員開發的代碼,我必須修改一下。下面的代碼:在PHP中顯示Oracle日期時間格式
<html>
<head>
<title> PAYMENT LIST </title>
<script language="javascript" type="text/javascript">
function urlorder(a)
{
var urlorder="order.php?on="+a;
var prmpt=window.open(urlorder,"test","left=200,top=150,scrollbars=yes,resizable=no,width=640,height=480");
}
function printorder(a,b)
{
var urlorder="printorder.php?on="+a+"&nu=2&tgl="+b;
//var prmpt=window.open(urlorder,"test","left=200,top=150,scrollbars=yes,resizable=no,width=640,height=480");
window.location = urlorder;
//alert (urlorder);
}
</script>
</head>
<body>
<?
//include "ceksession.php";
include 'connect.php';
//ambil tgl val
$q = "select tgl_val from para_info_kntr";
$s = OCIParse($c,$q);
OCIBindByName($s,":bind1",$ltid);
OCIExecute($s,OCI_DEFAULT);
while (OCIFetch($s))
{
$tgl=ociresult($s,"TGL_VAL");
echo $tgl."<br>";
}
$tgl= date('d-m-Y', strtotime($tgl));
$tgl= date('d-m-Y');
//echo $tgl."<br>";
$tgl = $_GET["tgl"];
echo "<div align=\"right\">";
echo "<input type=\"button\" onclick=\"window.location='month.php'\") value=\"HOME\">";
echo "</div>";
echo "<div align=\"center\">";
echo "<table border=\"1\">";
echo "<tr><td colspan=\"44\">";
echo "<div align=\"center\">PAYMENT LIST</div>";
echo "</td></tr>";
$q = "Select * from payment_final where bt_number=".$bt_number." and to_char(tgl_val,'DD-MM-YYYY')='".$tgl."' order by bill_no";
//echo $q;
$s2=OCIParse($c_slave,$q);
OCIBindByName($s2,":bind1",$ordernumber);
OCIExecute($s2,OCI_DEFAULT);
echo "<tr><td>";
echo "PAYMENT_NUMBER";
echo "</td><td>";
echo "TABLE_ID";
echo "</td><td>";
echo "ORDER_NUMBER";
echo "</td><td>";
echo "TGL_VAL";
echo "</td><td>";
echo "PAY_DATE";
echo "</td><td>";
echo "AMOUNT";
echo "</td><td>";
echo "DISCOUNT_AMOUNT";
echo "</td><td>";
echo "SERVICES";
echo "</td><td>";
echo "TAX";
echo "</td><td>";
echo "TOTAL_AMOUNT";
echo "</td><td>";
echo "BILL_NO";
echo "</td><td>";
echo "PRINT";
echo "</td></tr>";
while (OCIFetch($s2))
{
$V_GUEST_FOLIO = oci_result($s2,'GUEST_FOLIO');
$V_PAYMENT_NUMBER = oci_result($s2,'PAYMENT_NUMBER');
$V_TABLE_ID = oci_result($s2,'TABLE_ID');
$V_ORDER_NUMBER = oci_result($s2,'ORDER_NUMBER');
$V_TGL_VAL = oci_result($s2,'TGL_VAL');
$V_PAY_DATE = oci_result($s2,'PAY_DATE');
$V_AMOUNT = oci_result($s2,'AMOUNT');
$V_DISCOUNT_MK = oci_result($s2,'DISCOUNT_MK');
$V_DISCOUNT_MN = oci_result($s2,'DISCOUNT_MN');
$V_DISCOUNT_KM = oci_result($s2,'DISCOUNT_KM');
$V_DISCOUNT_SN = oci_result($s2,'DISCOUNT_SN');
$V_DISCOUNT_EA = oci_result($s2,'DISCOUNT_EA');
$V_DISCOUNT_EB = oci_result($s2,'DISCOUNT_EB');
$V_DISCOUNT_AMOUNT = oci_result($s2,'DISCOUNT_AMOUNT');
$V_SERVICES = oci_result($s2,'SERVICES');
$V_TAX = oci_result($s2,'TAX');
$V_TOTAL_AMOUNT = oci_result($s2,'TOTAL_AMOUNT');
$V_CASH_PAID = oci_result($s2,'CASH_PAID');
$V_CASHIER_NUMBER = oci_result($s2,'CASHIER_NUMBER');
$V_WAITER_NUMBER = oci_result($s2,'WAITER_NUMBER');
$V_CUSTOMER_NUMBER = oci_result($s2,'CUSTOMER_NUMBER');
$V_PRINT_DATE = oci_result($s2,'PRINT_DATE');
$V_DP = oci_result($s2,'DP');
$V_CARD_PAID1 = oci_result($s2,'CARD_PAID1');
$V_CARD_PAID2 = oci_result($s2,'CARD_PAID2');
$V_CARD_TYPE1 = oci_result($s2,'CARD_TYPE1');
$V_CARD_NUMBER1 = oci_result($s2,'CARD_NUMBER1');
$V_CARD_NAME_HOLDER1 = oci_result($s2,'CARD_NAME_HOLDER1');
$V_CARD_TYPE2 = oci_result($s2,'CARD_TYPE2');
$V_CARD_NUMBER2 = oci_result($s2,'CARD_NUMBER2');
$V_CARD_NAME_HOLDER2 = oci_result($s2,'CARD_NAME_HOLDER2');
$V_PAYMENT_METHOD = oci_result($s2,'PAYMENT_METHOD');
$V_AR_AMOUNT = oci_result($s2,'AR_AMOUNT');
$V_BT_NUMBER = oci_result($s2,'BT_NUMBER');
$V_FLAG_CETAK = oci_result($s2,'FLAG_CETAK');
$V_REC_ID = oci_result($s2,'REC_ID');
$V_FLAG_CTR = oci_result($s2,'FLAG_CTR');
$V_CHECK_NO = oci_result($s2,'CHECK_NO');
$V_VOUCHER = oci_result($s2,'VOUCHER');
$V_VOUCHER_NO = oci_result($s2,'VOUCHER_NO');
$V_CPL_AMOUNT = oci_result($s2,'CPL_AMOUNT');
$V_BILL_NO = oci_result($s2,'BILL_NO');
$V_AR_NAME = oci_result($s2,'AR_NAME');
$V_ENT_AMOUNT = oci_result($s2,'ENT_AMOUNT');
echo "</td><td>";
/*
<input type=\"button\" value=\"".$V_PAYMENT_NUMBER."\" onclick=\"urlorder(".$V_ORDER_NUMBER.")\")\" style=\"height: 25px; width: 70px;\">
*/
echo "<a href=\"order.php?on=".$V_ORDER_NUMBER."\">";
echo $V_PAYMENT_NUMBER;
echo "</a>";
echo "</td><td>";
echo $V_TABLE_ID;
echo "</td><td>";
echo $V_ORDER_NUMBER;
echo "</td><td>";
echo $V_TGL_VAL;
echo "</td><td>";
echo $V_PAY_DATE;
echo "</td><td>";
echo $V_AMOUNT;
echo "</td><td>";
echo $V_DISCOUNT_AMOUNT;
echo "</td><td>";
echo $V_SERVICES;
echo "</td><td>";
echo $V_TAX;
echo "</td><td>";
echo $V_TOTAL_AMOUNT;
echo "</td><td>";
echo $V_BILL_NO;
echo "</td><td>";
echo "<input type=\"button\" onclick=\"printorder(".$V_ORDER_NUMBER.",'".$tgl."')\") value=\"PRINT\">";
echo "</td></tr>";
}
?>
</body>
</html>
結果如下所示:
在我的數據庫的Oracle,現場PAY_DATE的格式是這樣的:2015年2月1日8時35分58秒 但結果現在它只顯示日期。我想要做的是我想在PAY_DATE列中顯示像這樣的日期和時間02/01/2015 08:35:58。你們能幫助我嗎?
嘿,我可以把代碼放在哪裏? – yogieputra 2015-03-31 06:02:39
放入您的SQL查詢選擇日期字段。 – 2015-03-31 06:04:21
$ q =「Select * from payment_final where bt_number =」。$ bt_number。「and to_char(tgl_val,'DD-MM-YYYY')='」。$ tgl。「order by bill_no」;從payment_final中選擇to_char(「PAY_DATE」,「YYYY-MM-DD HH:MI:SS」)作爲「PAY_DATE」,其中bt_number =「。$ bt_number。」和to_char(tgl_val) ,'DD-MM-YYYY')='「。$ tgl。''order by bill_no」;這是你的意思嗎? – yogieputra 2015-03-31 06:08:35