Page 1 of 1

compare dates

Posted: Sun Jul 05, 2009 12:10 pm
by nite4000
I am needing some assistance with how to compare dates

I need to take a date someone signes up and compare to current date and then if its more then 15 days have it suspend

I am can the quesry to suspend and all but getting it to compare the dates is what i need help with

If anyone can provide a example or something it would help.

Thanks

Re: compare dates

Posted: Sun Jul 05, 2009 1:27 pm
by William

Code: Select all

 
 
// Set variables
$fifteen_days = 1296000;
 
if ( ( time() + $fifteen_days ) < $input_timestamp ) {
    // The date is later than 15 days in the future.
}
 
Do something like that. In terms of setting $input_timestamp, you can use http://www.php.net/strtotime or http://www.php.net/mktime or a few others. Check the manual. :-)

Re: compare dates

Posted: Sun Jul 05, 2009 2:29 pm
by nite4000
what is $input_timestampe is that the same as the current date

What I need to do is take teh date in a table in a field called joindate and chk to see if its been more then 15 days to the current date.

I also need to know how to get the number for 15 days i see 1296000 how is that done also what would it be for a day since i will need to test this script

Thanks
William wrote:

Code: Select all

 
 
// Set variables
$fifteen_days = 1296000;
 
if ( ( time() + $fifteen_days ) < $input_timestamp ) {
    // The date is later than 15 days in the future.
}
 
Do something like that. In terms of setting $input_timestamp, you can use http://www.php.net/strtotime or http://www.php.net/mktime or a few others. Check the manual. :-)

Re: compare dates

Posted: Sun Jul 05, 2009 3:50 pm
by paqman
You can go

Code: Select all

$input_timestamp = time();
to get the current unix timestamp (for the time when the server completed the request).

60 seconds/minute * 60 minutes/hour * 24 hours/day * 15 days = 1296000 seconds (15 days)