 |
php mysql บวกเพิ่ม วันที่มีอยู่แล้วใน ดาต้าเบส ควรทำยังไงดีค่ะ |
|
 |
|
|
 |
 |
|
ลอง apply ดูครับ
Code (PHP)
<?
$result="2013-02-11";
echo $time = date("Y-m-d ", strtotime("+7 day",strtotime($result)));
?>
|
 |
 |
 |
 |
Date :
2013-02-11 16:53:00 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รูปแบบไหนฐานข้อมูล $order_date คุณได้ทำการเก็บในรูปแบบไหนครับ
date("Y-m-d"); หรือ date("Y-m-d H:i:s");
|
 |
 |
 |
 |
Date :
2013-02-11 17:29:00 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$date_pay=date("Y-m-d",strtotime("+15 day",strtotime($order_date)));
ผิดตรงที่ คุณเรียก strtotime($order_date) อีกครั้ง ซึ่งไม่จำเป็น
และผิดที่ $order_date นั้นเป็นชนิด array
เพราะได้ค่ามาจาก $order_date=mysql_fetch_array($dbquery);
ดังนั้นต้องอ้างถึงค่ามันโดยตรง
Code (PHP)
$date_pay=date("Y-m-d",strtotime("+15 day",$order_date['order_date']));
|
 |
 |
 |
 |
Date :
2013-02-11 17:33:59 |
By :
cookiephp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณทุกท่านสำหรับคำแนะนำดีๆค่ะ
$sql="select order_date from sell_order where sell_order_id='$sell_order_id'";
$dbquery=mysql_query($sql) or die (mysql_error());
$order_date=mysql_fetch_array($dbquery);
$dd=$order_date['order_date'];
$date=date("Y-m-d",strtotime("+7 day",strtotime($dd)));
|
ประวัติการแก้ไข 2013-02-12 01:52:34
 |
 |
 |
 |
Date :
2013-02-12 01:50:05 |
By :
sunaree |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|