首页 > 解决方案 > PHP - 显示日期和时间是否在过去

问题描述

问题

我正在用 PHP 编写一个系统来显示全天在游戏中托管的事件,但是我遇到了一个问题,它显示所有事件都已完成,而不仅仅是基于时间完成的事件。

我试过的

我试图使用 time() 来跟踪时间。代码示例:

$gendate = new DateTime();
$gendate->setISODate("2020",$week,$day); //year , week num , day
$timestamp = $gendate->format('d-m-Y');
$timestamp .=$fullhour;
$timestamp = strtotime($timestamp);
$dayno = $day;
$today_hour = ('H');

<? if( $timestamp < time() ) { ?><div class="right" style="margin: 16px 16px 0px 0px; margin-top: 22px;">
<h10>
<div style="background-image: url(http://habboemotion.com/resources/images/icons/button_3.gif); background-repeat: no-repeat; height: 200px; width: 300px; float: right; margin-right: -200px;"><p style="margin-top: 5px; margin-bottom: -20px; margin-left: 15px;">
Completed</p>
</div>
</h10>
</div><? } ?>

问题

我将如何告诉它跟踪过去的时间和日期,以便它在已完成的事件下显示已完成?

标签: php

解决方案


忽略这一点,我没有为 $fullhour 创建变量


推荐阅读