Home >Backend Development >PHP Tutorial >A gadget that calculates how long it will take until you get off work

A gadget that calculates how long it will take until you get off work

WBOY
WBOYOriginal
2016-07-25 08:50:301205browse
Do not spray with slag technology
  1. $friday = strtotime("next Friday 18:00:00");
  2. $time = time();
  3. $s = $friday-$time;
  4. $days = floor($ s/24/60/60); //Remaining days
  5. $hour = floor( ($s-$days*24*60*60)/60/60); //Remaining hours
  6. $minute = floor( ($ s-$days*24*60*60-$hour*60*60)/60 ); //Remaining minutes
  7. $second = floor($s-$days*24*60*60-$hour*60*60 -$minute*60); //Remaining seconds
  8. echo json_encode(array('days'=>$days , 'hour'=>$hour , 'minute'=>$minute , 'second'=> ;$second ));
  9. ?>
Copy code
  1. How much longer? Liberation
  2. Lijiejie Also: dayshours seconds
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn