簡體   English   中英

詢問從當前日期到未來7天以及過去7天的數據

[英]ask data's from current date to 7 days ahead and past 7 days

我正在嘗試每周選擇一堆游戲。 我怎樣才能做到這一點。 它假定顯示當前時間+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"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM