【问题标题】:PHP - Show if date and time is in the pastPHP - 显示日期和时间是否在过去
【发布时间】:2020-06-30 13:21:16
【问题描述】:

问题

我正在用 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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多