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
compare dates
Moderator: General Moderators
Re: compare dates
Code: Select all
// Set variables
$fifteen_days = 1296000;
if ( ( time() + $fifteen_days ) < $input_timestamp ) {
// The date is later than 15 days in the future.
}
Re: compare dates
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
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: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.Code: Select all
// Set variables $fifteen_days = 1296000; if ( ( time() + $fifteen_days ) < $input_timestamp ) { // The date is later than 15 days in the future. }
Re: compare dates
You can go 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)
Code: Select all
$input_timestamp = time();60 seconds/minute * 60 minutes/hour * 24 hours/day * 15 days = 1296000 seconds (15 days)