Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 询问从当前日期到未来7天以及过去7天的数据_Php_String_Strtotime - Fatal编程技术网

Php 询问从当前日期到未来7天以及过去7天的数据

Php 询问从当前日期到未来7天以及过去7天的数据,php,string,strtotime,Php,String,Strtotime,我试图每周选择一系列比赛。我怎样才能做到这一点。 它假定显示当前时间+7天和-7天之前和新游戏的数据 目前,我有这个 function testFR (){ $DateFrom = new DateTime(); $DateTo = new DateTime(); $DateTo->add(new DateInterval("P7D")); $laMatches = (array)WaterpoloAPICached::call("Matche

我试图每周选择一系列比赛。我怎样才能做到这一点。 它假定显示当前时间+7天和-7天之前和新游戏的数据

目前,我有这个

function testFR (){
     $DateFrom  = new DateTime();
     $DateTo    = new DateTime();
     $DateTo->add(new DateInterval("P7D"));
    $laMatches = (array)WaterpoloAPICached::call("Matches", "getMatches", Array(
        isset($_GET["SeasonId"]) ? $_GET["SeasonId"] : "",
        isset($_GET["DepartmentId"]) ? $_GET["DepartmentId"] : "",
        isset($_GET["ClubId"]) ? $_GET["ClubId"] : "",
        isset($_GET["TeamId"]) ? $_GET["TeamId"] : "",
        isset($_GET["PoolId"]) ? $_GET["PoolId"] : "",
        date_format($DateFrom,  'd-m-Y'),
        date_format($DateTo,    'd-m-Y'),
        isset($_GET["RefereeId"]) ? $_GET["RefereeId"] : "",    
    )); 
    // Sort Matches ascending
       usort($laMatches, function($a, $b) {
                       return stringToUnix($a->Date) - stringToUnix($b->Date);
       });
/* echo "<h6 id='rcorners' style='background-color:#3db7e4; padding: 1rem; color:white;'><strong>Wedstrijden</strong></h6>"; */
    echo "<table class='hover'>";
    echo "<tbody >";        
    $lnToday = date("d-m-Y", strtotime("+7 days"));                       
                          $lcCurrent = "";                        
       foreach($laMatches as $loMatch) {
           if(stringToUnix($loMatch->Date) >= $lnToday) {
                if($lcCurrent != $loMatch->Date) {     
            echo "<thead>";
            echo "<tr >";
            echo "<th class='text-center'>";
            echo "$loMatch->Date</th>";
            echo "<th class='text-center'></th>";      
            echo "<th class='text-center'></th>";
            echo "<th class='text-center'></th>";
            echo "<th class='text-center'>Division</th>";
            echo "</tr>";                 
            echo "</tr>
                </thead>";         
                    }               
                    $lcCurrent = $loMatch->Date;                       
            echo "<tr class='text-center'>";
                echo "<td >$loMatch->Time</td>";
                echo "<td>$loMatch->HomeTeam </td>";
                echo "<td><strong><a href='..\match?MatchId=".$loMatch->Id."&Report=".$loMatch->MatchReport."'>$loMatch->ResultHome - $loMatch->ResultGuest </a></strong></td>";
                echo "<td> $loMatch->AwayTeam</td>";
                echo "<td> $loMatch->DepartmentName</td>";
            echo "</tr>";   
            }
        }      
        echo "</tbody>";
        echo "</table>";        
}

问题解决了!对于那些有类似问题的人…希望这有帮助

你差点就成功了。您可以按如下程序方式从日期中添加/减去时间段:

$lnToday = date("d-m-Y", strtotime("+7 days"));

你差点就成功了。您可以按如下程序方式从日期中添加/减去时间段:

$lnToday = date("d-m-Y", strtotime("+7 days"));

如您所见,标记已被编辑。这里没有jQuery,除非您想将逻辑移到clientthx Rory!对于editAs,您可以看到标记已被编辑。这里没有jQuery,除非您想将逻辑移到clientthx Rory!对于编辑来说,仍然可以得到所有游戏的列表。我做错了什么?我已经编辑了我到目前为止的内容。。我还需要一个开始时间和结束时间吗?很抱歉听到这个消息。$loMatch->Date返回了什么?我很高兴听到这个消息。仍然在获取所有游戏的列表。我做错了什么?我已经编辑了我到目前为止的内容。。我还需要一个开始时间和结束时间吗?很抱歉听到这个消息。$loMatch->Date返回什么?我很高兴听到这个消息。