Php 当退房时间为中午12:00时,根据签到退房计算入住天数

Php 当退房时间为中午12:00时,根据签到退房计算入住天数,php,datetime,datediff,Php,Datetime,Datediff,这里最简单的方法是在mysql上计算不同的日期 <?php $today = date('Y-m-d'); $sql = "SELECT * FROM roombooking where enddate>='$today'" ; $result1 = $db->query($sql); if ($result1->num_rows > 0){ echo" <div class=table-responsive

这里最简单的方法是在mysql上计算不同的日期

<?php
    $today = date('Y-m-d');
    $sql = "SELECT * FROM roombooking where enddate>='$today'" ;

    $result1 = $db->query($sql);
    if ($result1->num_rows > 0){
    echo"
    <div class=table-responsive border >
      <table class=table>
        <tr>

        <th>Room Type</th>
        <th>Room Number</th>
        <th> Status </th>
        <th> Check-in date </th>
        <th> Check-Out date  </th>
        <th>Stay Time</th>
        <th colspan='2'>Action </th>
        </tr>";
        // output data of each row

        // output data of each row
        while ($row = $result1->fetch_assoc()) 
        { echo "<tr>
               <td>".$row["roomtype"]."</td>
               <td>".$row["roomnumber"]."</td>
               <td>".$row["bkg_status"]."</td>
               <td>".$d1=$row["bkg_clientintime"]."</td>
               <td>".$d2=$row["bkg_clientouttime"]."</td>


               </tr>";
            }
     echo "</table></div>";
    }else { echo "<br>"."<div class='alert alert-info col col-md-6 col-md-offset-2'> SORRY NO CHEK OUT FOUND FOR TODAY 

    </div> ";}
?>
//here from $d1 which is booking check-in-date and $d2 which is check-out-date 
HELP REQUIRED // important checkout date time is 12.00 noon 
HELP REQUIRED 2// FINDING TOTAL Number of days stay 

any suggestion are greatly appreciated 
tried here date_diff / it again gives hours or days but have to find based on
12.00 noon important checkout otherwise new day will be added  how to achieve this part  kindly guide

在$d2之后,我想回显客人的总停留天数如何计算??如果退房时间是中午12点很重要谢谢Dilipen先生。。但如何根据退房日期差异在中午12:00检查,而不是更改日期。。客户可能会在结账时间前5小时(即中午12:00)办理结账手续,因此他将自行支付全天的费用。。然后,我们需要根据不同的剩余日期计算剩余时间。我认为首先,您需要找到总的不同小时数,并将其转换为天“```选择CEILTIMESTAMPDIFFHOUR、'2009-05-18 11:45:42'、'2009-05-20 15:16:39'/24作为无天数```嗨,datediff帮助获取数据,以及进出的天数差,但是如果客人早上5点进来,他的结账时间是中午12点,因此,当客人在夜间凌晨1点离开时,只会显示1天,如应显示的2天,如从凌晨5点到中午12点=1天,从中午12点到凌晨1点,因此2天的停留时间如何实现这一点感谢您的帮助是宝贵的,非常有用//抱歉,我错投了否决票,两次,但当我理解了正确答案时,我选择了勾选,为了控制伤害,我使用了两次循环法而不是CEIL。它将返回您期望的答案Hi Dilipen D感谢您的宝贵意见我尝试了function ROUND和CEIL,但没有按照预期工作,如选择CEILTIMESTAMPDIFFHOUR、'2009-05-18 1:30:00'、'2009-05-18 15:16:39'/24作为no_days&选择RoundTimesDiffHour、'2009-05-18 1:30:00','2009-05-18 15:16:39'/24因为无天数结果是01天,但这是错误的,因为退房时间是中午12点而不是中午
SELECT *,
  DATE_DIFF(DATE(bkg_clientintime), DATE(bkg_clientouttime)) AS no_days
FROM roombooking