I need a bit of help with a php time stamp script, basicly I need a script that gets a stored time from the database, and reads its and does 1 of two things,
If the time in the database in under 24 hours from this time it either echos come back after 24 hours or the exact time left, and if the time is over 24 hours it echo thanks ( I will change this bit latter)
I am not sure how to approach this so all help is appreciated
Assuming $time is your stored timestamp try something like:
PHP Code:
// $time = your stored timestamp
if(($time - time()) >= 86400)
{
// if timestamp minus current timestamp is greater than or equal to the number of seconds in 24 hours
echo 'Thanks!';
}
else
{
echo 'Come back in ' . date('h \h\ou\r\s i \m\i\nu\t\e\s s \s\e\c\o\n\d\s', ($time - time()));
}
To try it out just make up a random timetamp like so:
PHP Code:
$time = time() - mt_rand(1, 86400);
(obviously that will change everytime the page loads but it's just to show it working)
Matt
__________________ My NamePros Tools (firefox plugin, google gadget etc)
Yes, although if you used <= instead of just < then for the 1 second where timestamps are exact, it would give you the opposite output than what you want. (but that would only be for 1 second)
__________________ My NamePros Tools (firefox plugin, google gadget etc)