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

  • Home
  • SEARCH
  • 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 8703471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:52:37+00:00 2026-06-13T02:52:37+00:00

Let’s say I have this piece of code running inside a loop where $fid

  • 0

Let’s say I have this piece of code running inside a loop where $fid will receive a value at each round:

     $result2 = mysql_query( "SELECT date_create FROM users WHERE id = $fid");

Now, date_create will be in the format e.g

2012-08-16 20:13:49

My question is, how do I check if that date is before 2012-08-31, like 2012-08-10 ?

My full code, just in case one asks about it.

$query = "(SELECT distinct fid FROM coin WHERE uid = 59  )";
$result = mysql_query($query);
while($rows = mysql_fetch_array($result))
{
    $fid = $rows['fid'];
    echo 'fid || '.$fid;
    $result2 = mysql_query( "SELECT id, date_create FROM users WHERE id = $fid");
     $rows2 = mysql_fetch_array($result2);

     echo "  ||   users id : " . $rows2['id']; 

     if( $rows2['date_create'] < "2012-8-31") // How do i get something like this? 
     {

          echo "  ||   date_create : " . $rows2['date_create'] ." True"; 

     }
     else
     {
           echo "  ||   date_create : " . $rows2['date_create'] . "False"; 
     }  
    l();
}

Result I get so far is something like:

fid || 1112 || users id : 1112 || date_create : 2012-08-16 20:13:49 false <--
fid || 1113 || users id : 1113 || date_create : 2012-08-16 20:14:11 false <--
fid || 1115 || users id : 1115 || date_create : 2012-08-16 20:14:21 false <--
fid || 1117 || users id : 1117 || date_create : 2012-08-16 20:14:38 false <--
fid || 1118 || users id : 1118 || date_create : 2012-08-16 20:15:03 false <--
fid || 1119 || users id : 1119 || date_create : 2012-08-16 20:15:10 false <-- 

n.b would appreciate if also you could provide a way to check time. This would be extra 😀

  • 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-13T02:52:39+00:00Added an answer on June 13, 2026 at 2:52 am

    You can do it by converting the date/time string and compare it using strtotime(). Using that method, you can also adapt it to compare for seconds as well:

    //this effectively checks to see that the time is greater than '2012-08-16 20:13:49'
    //the total calculated time on the RHS of the >= operator is effectively '2012-08-16 20:13:49'
    //hence, this will echo 'YES'
    
    //this is of the form: hours, minutes, seconds
    $time_difference = (44 * 60 * 60) + (13 * 60) + 49;
    
    if (strtotime('2012-08-16 20:13:49') >= strtotime('2012-08-15') + $time_difference)
    {
      echo 'YEAH';
    }
    else
    {
      echo 'NO';
    }
    

    UPDATE:

    From the PHP documentation on strtotime():

    The valid range of a timestamp is typically from Fri, 13 Dec 1901
    20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates
    that correspond to the minimum and maximum values for a 32-bit signed
    integer.) Additionally, not all platforms support negative timestamps,
    therefore your date range may be limited to no earlier than the Unix
    epoch. This means that e.g. dates prior to Jan 1, 1970 will not work
    on Windows, some Linux distributions, and a few other operating
    systems. PHP 5.1.0 and newer versions overcome this limitation though.

    For 64-bit versions of PHP, the valid range of a timestamp is
    effectively infinite, as 64 bits can represent approximately 293
    billion years in either direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have an facebook application running using the JS SDK. First user
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say you have a method that expects a numerical value as an argument.
Let's say you have an array like this: array ( ['one'] => array (
Let's say you have a string that looks like this: token1 token2 tok3 And

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.