我试图每周选择一堆游戏。我该怎么做到这一点。 它假设从当前时间+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>";
}
问题已经解决了!对于那些遇到类似问题的人......希望得到这个帮助!
答案 0 :(得分:0)
你几乎得到了它。您可以按照以下过程方式从日期添加/减去时间段:
$lnToday = date("d-m-Y", strtotime("+7 days"));