Round Time to Nearest


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function roundTime($blnRoundDown = true) {
  2. $seconds = time();
  3.  
  4. $rounded_seconds = ($blnRoundDown) ? floor($seconds / (5 * 60)) * (5 * 60) : round($seconds / (5 * 60)) * (5 * 60);
  5.  
  6. return date('H:i', $rounded_seconds);
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.