简体   繁体   中英

PHP - Show if date and time is in the past

Problem

I'm programming a system in PHP for showing events that have been hosted on a game throughout the day, however I have hit an issue where it shows completed on ALL events and not just events that have been completed based on time.

What I've tried

I have attempted to use time() to track the time. Code example:

$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><? } ?>

Question

How would I go about telling it to track time and date is in the past so that it shows completed under completed events?

Ignore this, I didn't create a variable for $fullhour

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM