PHP:如何在两个日期和日历之间获得一整天的时间

PHP:如何在两个日期和日历之间获得一整天的时间,php,Php,我有两个约会: 2014年11月10日和2014年11月17日 现在我想知道这两者之间的所有日期 然后我需要检查它在日历上,如果它在日历上,我需要在红色的颜色 我该怎么做 这是我的日历代码:- <Table class="grayBg" align="center" style="font-family: 'trebuchet MS';font-size:12px" width="288"> <caption style="font-weight:bold;paddin

我有两个约会:

2014年11月10日和2014年11月17日

现在我想知道这两者之间的所有日期

然后我需要检查它在日历上,如果它在日历上,我需要在红色的颜色

我该怎么做

这是我的日历代码:-

<Table class="grayBg" align="center" style="font-family: 'trebuchet MS';font-size:12px" width="288">
    <caption style="font-weight:bold;padding-bottom:2px" class="black font10px">
<?php
if(file_exists('winneradmincpanel/connect.php'))
{
    require_once('winneradmincpanel/connect.php');
    $connect = new connect();
    include 'config.php';

    require_once('date/hjreedate.php');
    $hijri = new HijriCalendar();

    include('date/hdate.php');
    $date = $hijri -> GregorianToHijri(time());
    $hdate =  $aday." ".$date[1].' '.$hijri ->monthName($date[0]).' '.$date[2] ." هـ";  

/// get current month and year and store them in $cMonth and $cYear variables
(intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m");
(intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y");

echo GregorianHijri::getMonthName ( $m,GregorianHijri::$GREGORIAN,$GLOBALS['lang']) . ' ' . $a;
// generate an array with all dates with events


?> 
</caption>
<tr style="background:#CCCCCC">
    <th>الاثنين</th>


    <th>الثلاثاء</th>


    <th>الاربعاء</th>


    <th>الخميس</th>


    <th>الجمعة</th>


    <th>السبت</th>


    <th>الاحد</th>
</tr>    
<?php
$ts = mktime ( 1, 0, 0, $m, 1, $a );
$detail = getdate ( $ts );
echo "<tr>";
if ($detail ['wday'] == 0)
    $nb = 6;
else
    $nb = $detail ['wday'] - 1;
for($j = 1; $j <= $nb; $j ++)
    echo "<td>";
$n = $detail ['wday'];
$valid = TRUE;
$j = 1;
$monthsArray = array();
do {

    $valid = checkdate ( $m, $j, $a );
    if ($valid) {
        //$dateOutput = "$a-$m-$j";
        $dateOutput = sprintf ( $GLOBALS['gregorianDateFormat'], $a,$m,$j);
        $hijriDay = GregorianHijri::hijriDay($a,$m,$j,$GLOBALS['lang']);
        $explod = explode("-",$hijriDay);
        $year = $explod[1];
        $day = $explod[0];
        $hijriDate = GregorianHijri::hijriDate($a,$m,$j,$GLOBALS['lang'],$GLOBALS['hijriDateFormat']);
        $hijriMonth = GregorianHijri::hijriMonth($a,$m,$j,$GLOBALS['lang']);
        array_push($monthsArray,$hijriMonth);



        $sql = "SELECT * FROM tarshoh WHERE `datedurationm`";
        $sql_result = mysql_query ($sql) or die ('request "Could not execute SQL query" '.$sql);
        while ($row = mysql_fetch_assoc($sql_result)) {
            $events[$row["event_date"]]["dawracat"] = $row["dawracat"];
            $events[$row["event_date"]]["datedurationm"] = $row["datedurationm"];
            }

            $currntm = $events[$row["event_date"]]["datedurationm"];
            $currnth = $events[$row["event_date"]]["datedurationh"];




            if(!isset($_REQUEST['day'])){
                if($j == $currntm){
                    $bg = "#79c04b";
                 }else{
                    $bg = "";
                 }
            }else{

                if($j == $newDay){
                    //$bg = "#cccccc";
                }else{
                    //$bg = "";
                }
            }


            ///////////////////////




             $gregorianId = 'gregorianDate'.$j;
             $hijriId = 'hijriDate'.$j;
             $function = "getDateInputs('".$gregorianId."','".$hijriId."')";
        if (($j + $nb) % 7 == 1)



            echo "<tr>";
        echo "<td align=center style='font-size:10px;cursor:pointer' bgcolor='$bg' onclick=$function class='cel-calendar-border'>
                <table border='0' class='font10px' width='30' cellspacing='0' cellpadding='0' >
                    <tr><td align='left'><span class='black'>$j</span></td></tr>
                    <tr><td align='right' class='red'>$day</td></tr></table>";
        echo "<input type='hidden' name=$gregorianId id =$gregorianId value='$dateOutput'>";
     echo "<input type='hidden' name=$hijriId id =$hijriId value='$hijriDate'>";
     $j = $j+1;


     echo "</td>";

    }
   } while ($valid);

   $monthsArray = array_unique($monthsArray);
?>
</TABLE> 
<div align="center" style="font-size:10px;font-family:'trebuchet MS';padding-top:2px;padding-bottom:2px;font-weight:bold" class="red">
<?php 
$i=0;
foreach ($monthsArray as $key=> $value){ 
    $i++;
    echo $value;
    if ($i < count($monthsArray)){
        echo " / ";
    }
}
echo " ".$year;
}
?>
</div>
还有这里的日历:-

       echo "<tr>";
    echo "<td align=center style='font-size:10px;cursor:pointer' bgcolor='$bg' onclick=$function class='cel-calendar-border'>
            <table border='0' class='font10px' width='30' cellspacing='0' cellpadding='0' >
                <tr><td align='left'><span class='black'>$j</span></td></tr>
                <tr><td align='right' class='red'>$day</td></tr></table>";
    echo "<input type='hidden' name=$gregorianId id =$gregorianId value='$dateOutput'>";
 echo "<input type='hidden' name=$hijriId id =$hijriId value='$hijriDate'>";
 $j = $j+1;


 echo "</td>";

你能用它来编辑我的代码吗?我试过了,但我有一些错误。不,你得做这项工作。在阅读了手册的那一部分之后,如果有什么地方不起作用,请将您的最大努力发回。问一个特定的问题。它告诉我这个错误致命的错误:类“DateInterval”在任何PHP版本>=5.3中从哪里可以获得这个类。这是5年前,2009年6月发布的。是时候升级您的环境了?
       echo "<tr>";
    echo "<td align=center style='font-size:10px;cursor:pointer' bgcolor='$bg' onclick=$function class='cel-calendar-border'>
            <table border='0' class='font10px' width='30' cellspacing='0' cellpadding='0' >
                <tr><td align='left'><span class='black'>$j</span></td></tr>
                <tr><td align='right' class='red'>$day</td></tr></table>";
    echo "<input type='hidden' name=$gregorianId id =$gregorianId value='$dateOutput'>";
 echo "<input type='hidden' name=$hijriId id =$hijriId value='$hijriDate'>";
 $j = $j+1;


 echo "</td>";