php - 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><? } ?>
问题
我将如何告诉它跟踪过去的时间和日期,以便它在已完成的事件下显示已完成?
解决方案
忽略这一点,我没有为 $fullhour 创建变量
推荐阅读
- node.js - 我应该如何在 React 中实现 Google 登录(使用 Express 后端)
- javascript - 将 CSS 样式应用于 Datatable 中的特定列
- sandbox - 在自定义规则中禁用沙箱
- reactjs - 未处理的拒绝 (SyntaxError):JSON 输入的意外结束
- android - 为什么我在 Google Play 的 Crash Stack 报告中看不到我的业务代码
- postgresql - sqlalchemy 中的复合 WHERE 子句
- reactjs - 如何使用httpget方法通过.net核心中的url传递对象?
- c# - 路线在邮递员中无法正常工作,因此不允许发布
- django - 更新相关模型的时间戳
- python - 如何在 python 中做 aws iot 工作