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 8321721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:07:12+00:00 2026-06-08T23:07:12+00:00

I have the following code to see if the allotted time has passed. For

  • 0

I have the following code to see if the allotted time has passed.
For my demo it should all evaluate to false and nothing should happen.
What happens ever is that it parses to true, even inf I compare it with >=

Why do I get this strange behaviour?

$data = '[{"ip":"80.61.150.173","endtime":1343988643},{"ip":"80.61.150.173","endtime":1343988649},{"ip":"80.61.150.173","endtime":1343988650},{"ip":"80.61.150.173","endtime":1343988664},{"ip":"80.61.150.173","endtime":1343988682},{"ip":"80.61.150.173","endtime":1343988723}]';
$json = json_decode($data,true);
foreach($json as $key => $obj)
    {
    var_dump($obj);
    echo "<BR>";
    var_dump(time());
    echo "<BR>";
    if($obj['endtime'] <= time());
        {
        echo "<BR>bliep<P>";
        }
    }

This code evaluates to this result:

array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988643) }
int(1343981967)

bliep array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988649) }
int(1343981967)

bliep

array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988650) }
int(1343981967)

bliep

array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988664) }
int(1343981967)

bliep

array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988682) }
int(1343981967)

bliep

array(2) { [“ip”]=> string(13) “80.61.150.173” [“endtime”]=>
int(1343988723) }
int(1343981967)

bliep

As you can see, there are all blieps there that shouldn’t be there.
The timestamps are ints, the current time is smaller than the saved time.
It should compare easily, but it evaluates always to true, whilst now is < than the stored timestamp.

What’s going on here?

It’s not my server because this code also evaluates to true on http://writecodeonline.com/php/

  • 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-06-08T23:07:14+00:00Added an answer on June 8, 2026 at 11:07 pm

    I believe there’s a typo ; at the end if your if statement.

    Should’ve been

    if($obj['endtime'] <= time());
    

    instead of

    if($obj['endtime'] <= time())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I have the following code: http://jsfiddle.net/g7Cgg/ As you can see, there are
I have the following code on my page. http://jsfiddle.net/SO_AMK/r7ZDm/ As you see it's a
i have written the following code: As you can see there is a for
I have the following recursive code and it doesn't behave as expected (see details
I have the following code example (see below). My problem is that the tooltip
I have the following code which you're able to see what I am trying
I have the following code at http://jsfiddle.net/qPtXL/ As you can see the problem is
I have the following code. In SQL Server profiler I can see the insert
I am using the following code to see if user have internet connection (WIFI
I have written a following code (see code comments for the question), #include<stdio.h> int

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.