php - Take Current MYSQL Timestamp And Subtract It From 24 Hours -


one thing has confused me time in coding. confused on how go doing this! simply, have mysql timestamp, , want subtract 24 hours.

basically, trying code lets complete action once every 24 hours, , if try complete more once tell them how long have wait again.

this code have:

$dailylogincheck = 2015-08-16 13:30:32 //mysql timestamp date_default_timezone_set("america/new_york"); $lastloginbonus = new datetime($dailylogincheck); $currenttime = $lastloginbonus->diff(new datetime(date("y-m-d h:i:s"))); 

i don't have use code (if there better way this). subtract current timestamp 24 hours, have no clue how in php :( please help!

p.s. display sentence following: you have done within past 24 hours. please come in x hours x minutes , try again.

hope works :-)

   <?php   $dailylogincheck = '2015-08-16 13:30:32';  $end = new datetime($dailylogincheck); $end->add(new dateinterval('p1d'));//add 1 day find end date $now = new datetime('now');  $interval = $end->diff($now);  if($end->diff($now)->days >= 1){  echo 'go it';  }else{ echo $interval->format('%h hours, %i minutes until can xxx');  } 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -