Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6353083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:20:50+00:00 2026-05-24T22:20:50+00:00

Stack Overflow Community, I have always appreciated your wisdom and assistance. Here is my

  • 0

Stack Overflow Community,

I have always appreciated your wisdom and assistance. Here is my situation:

Here is a snippet of my XML file (this is a very small portion of it):

    <matchup id="1" date="09/08/11" time="7:30 PM">
        <away city="New Orleans">Saints</away>
        <home city="Green Bay">Packers</home>
        <finalscore>
            <away></away>
            <home></home>
        </finalscore>
    </matchup>

Okay, so using SimpleXML I am getting this XML data and storing it into respective PHP variables. The only thing I really need help with is the date/time section.

I am wanting to basically compare the date/time of the matchup to the current time. If the time of the matchup has already passed (or started for that matter), I want to display a different output.

So here is my PHP, but something is not working correctly here:

foreach($week->matchup as $matchup)
{
$game_time = $matchup['time'];
$game_date = $matchup['date'];

date_default_timezone_set('US/Eastern');
$game_date2 = strtotime($game_date);
$game_date3 = date('m/d/y', $game_date2);
$time_stamp = strtotime($game_time);
$check = date("g:i A", $time_stamp);
$date_now = date('m/d/y');
$time_now = date('g:i A');

if ($game_date3 >= $date_now && $check >= $time_now) {

?>
<tr>
<td class="two"><?php echo $game_date ?></td>
<td class="two">
<input type="radio" id="<?php echo $away_city ?> <?php echo $away_teamname ?>" class="radio" name="<?php echo $week_name ?>" value="<?php echo $away_city ?> <?php echo $away_teamname ?>"></input>
    <?php echo $away_full ?>
</td>
<td class="two">
<input type="radio" id="<?php echo $home_city ?> <?php echo $home_teamname ?>" class="radio" name="<?php echo $week_name ?>" value="<?php echo $home_city ?> <?php echo $home_teamname ?>"></input>
    <?php echo $home_full ?>
</td>
<td class="two"><?php echo $game_time ?></td>
</tr>
<?php
} else {
?>
<tr>
<td class="two"><?php echo $game_date ?></td>
<td class="two">
<span><?php echo $away_full ?></span>
</td>
<td class="two">
<span><?php echo $home_full ?></span>
</td>
<td class="two"><?php echo $game_time ?></td>
</tr>
<?php
}
    } ?>

As you can see here, what I am trying to do is simply check if the date/time from the XML is past the time of the current time. If it is, I want to display an output WITHOUT input radio buttons. If it is not past the current time, I want to display the output WITH input radio buttons.

I think the problem is somewhere in my variable setting with strtotime and getting the XML date/time to parse properly against the server time.

I hope someone can help me figure this out! Also, any recommendations to make this more concise and secure is appreciated as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:20:51+00:00Added an answer on May 24, 2026 at 10:20 pm

    You can’t compare date strings. You need to convert them to timestamps using strtotime then compare them.

    Like this:

    $date = '09/08/11 7:30 PM';
    
    if (strtotime($date) < time()) {
        // $date is in the past
    }
    

    So in your case:

    $game_time = $matchup['time'];
    $game_date = $matchup['date'];
    $date = "{$game_date} {$game_time}";
    
    if (strtotime($date) < time()) {
        // $date is in the past
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery code contributed by another member of the stack overflow community
Hi stack overflow community. I have 2 dynamic divs that I want to float
Dear Stack Overflow Community, I have a question regarding how to incorporate a WHERE
Hi Stack Overflow community. I'm developing a wordpress website for Satan. First of all,
With the help of the Stack Overflow community I've written a pretty basic-but fun
I'm wondering what the Stack Overflow community thinks when it comes to creating a
I have marked this question as community wiki, so no rep points are thrown
Greetings Stack Overflow community. I'm trying to make a function that can pop all
Let me thanks you guys at the Stack Overflow community for helping me with
How is the Community member/account of Stack Overflow work in terms of the ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.