I'm making a website for Esports team. As a part of match page, i want to have match status (Live or Match played, depending in a date / time). I have SQL table with all the dates & times set up and i'm pulling the dates & times from there correctly. (Checked with echo).
My current pieces of code look like this:
<?php
date_default_timezone_set("Europe/Helsinki");
$timeA = $date . ' ' . $time; ?>
<?php if ($format == 'BO1'): ?>
<?php $timeB = date("Y-m-d H:i", strtotime('+1 hours, +30 minutes', strtotime($timeA))); ?>
<?php else: ?>
<?php $timeB = date("Y-m-d H:i", strtotime('+3 hours, ', strtotime($timeA))); ?>
<?php endif ?>
This one is used to generate two times. $timeA is picking the current date & time (from SQL) and $timeB is being generated for when to set the match for "match over" status. (Depending in format).
If i now do echo $timeA & echo $timeB, it's echoing both times correctly like they should be. ($timeA being the expected start time & $timeB being the expected end time, both in y-m-d h:minutes format)
Now the part which isn't working.
I have following code set up:
<?php if ($timeB > $timeA){ ?>
<div class="match-done"> <b>Match over </b></div>
<?php } else { ?>
<div class="countdown" id="countdown"></div>
<?php } ?>
And no matter what i do, after $timeB has passed, it still shows the "else" part.
I have setup my code to echo both $timeA and $timeB and this is the output:
2019-04-10 18:35 2019-04-10 21:35
As you see, their both following the same format. Is there something i need to take in to the considering when both of those share same date but different time?
Aucun commentaire:
Enregistrer un commentaire