Forum Moderators: coopster
I have a quiz which people return to three months later. I want to check that they have waited at least three months.
The date they first arrived is stored in a variable 'stamp' using the mysql NOW() command, which enters the data like this;
2005-07-29 09:41:30
I would like to write a script that checks their username against the timestamp and if it is more than three months, allows them to continue.
Perhaps I could convert the NOW() into seconds?
Any suggestions most welcome.
if (strtotime("2005-02-29 09:41:30") > strtotime("-3 months"))
{
echo("Sorry, you need to wait a bit longer!");
}
MYSQL Page: [dev.mysql.com...]
Can go through it with you if you need help, I got confused for about 2 hours when I first looked at it.
If you're just interested in seconds rather than actual dates I would recommend working exclusively in time() [php.net] values, stored in your database using a long integer - INT(11).
PHP time() values are seconds since the Unix epoch of January 1 1970 00:00:00 so you'd have to do something more funky if you want to go way back...