从PHP将日期插入Oracle数据库 [英] Inserting date into oracle database from PHP
本文介绍了从PHP将日期插入Oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于将PHP中的日期插入Oracle DB的问题
I have a question regarding inserting date from PHP into Oracle DB
所以我在PHP中有这个
so i have this in my PHP,
$delivDate = strval($_POST['deliveryDate']);
echo $delivDate; //Just for checking
$delivInsertionSql = "INSERT INTO DELIVERY (DELIVERY_DATE)
VALUES (to_date('".$delivDate ."','MM/DD/YYYY hh24:mi:ss'))";
$delivInsertionParse = oci_parse($conn, $delivInsertionSql);
oci_execute($delivInsertionParse);
问题是,我没有在数据库中插入任何新记录.
DELIVERY_DATE的数据类型为DATE
The problem is, i dont see any new record inserted in the database.
the data type of DELIVERY_DATE is DATE
推荐答案
几天前,我遇到了同样的问题,那是日期格式问题.所以我更改了日期格式,它对我有用.您可以尝试下面的代码并进行测试,如果它可以工作,则可以根据需要修改代码.
Few days back I face the same issue and it was date format issue. So I change the date format and it works for me. You can try below code and test it and if it works than modify code as per your need.
$delivDate = date('d-m-Y h:i:s', strtotime($_POST['deliveryDate']));
INSERT INTO DELIVERY (DELIVERY_DATE) VALUES (to_date('".$delivDate."','dd-mm-yy hh24:mi:ss'))";
这篇关于从PHP将日期插入Oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文