Dynadot — .com Transfer

Php time help

SpaceshipSpaceship
Watch

Davic

Account Closed
Impact
0
Hi their,

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

Thanks

Davic
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Assuming $time is your stored timestamp try something like:

PHP:
// $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:
$time = time() - mt_rand(1, 86400);

(obviously that will change everytime the page loads but it's just to show it working)

Matt
 
Last edited:
0
•••
Thanks for that works a wonder, obviously if I change >= <= that would do the same just about the oppsite way correct?
 
0
•••
Davic said:
Thanks for that works a wonder, obviously if I change >= <= that would do the same just about the oppsite way correct?

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)
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back