หาคนแก้ สคริป php เล็กๆ น้อยๆ คำนวณ วันเวลา จองรถ
เช่น
เลือกวันที่จอง 19-12-2018 เวลา 16.00 น.
วันที่คืนรถ 21-12-2018 เวลา 12.00 น.
จะคำนวณเป็น 1 วัน 20 ชม.
คนเก่าเค้าเขียนไว้ มันจะติด ลบ เป็น 2 วัน -4 ชม.
ซึ่งของเก่าเขียนไว้ การคำนวณจะผิด
ด่วนครับ แจ้งราคามา ขอไม่แพงครับ
ตัวอย่างสคริปเก่า
<?php
function DateDiff($strDate1,$strDate2){
return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 );
}
function TimeDiff($strTime1,$strTime2){
return (strtotime($strTime2) - strtotime($strTime1))/ ( 60 * 60 );
}
function DateTimeDiff($strDateTime1,$strDateTime2){
return (strtotime($strDateTime2) - strtotime($strDateTime1))/ ( 60 * 60 );
}
$DateDiffTimeDiff = DateTimeDiff($item['pick_date'].' '.$item['pick_time'],$item['return_date'].' '.$item['return_time']);
$DateDiff = DateDiff($item['pick_date'],$item['return_date']);
$TimeDiff = TimeDiff($item['pick_time'],$item['return_time']);
/*
1-6 day 3 H = 147 h
1-29 day 3 H = 699 h
*/
$TimeDif = $TimeDiff > 3 ? 1 : 0;
$DateDif = $DateDiff==0 ? 1+$TimeDif : $DateDiff+$TimeDif;
$Navigation = $DateDif==0 ? 300*1 : 300*$DateDif;
$Child_Seat = $DateDif==0 ? 400*1 : 400*$DateDif;
if($DateDiffTimeDiff<=147){
$Perday = 'Per day';
$Price = $item['price2'];
}elseif($DateDiffTimeDiff<=699){
$Perday = 'Per Week';
$Price = $item['price'];
}else{
$Perday = 'contact';
$Price = 0;
}
?>
นัฐวุฒิ ศรีหะ
091-925-6516
[email protected]157 ถ.ติวานนท์ ต.ท่าทราย อ.เมือง จ.นนทบุรี