/** * @param $startPoint * @param null $endPoint * @return mixed */ function getDuration($startPoint, $endPoint = null) { if (!$endPoint) { $endPoint = time(); } $secs = $endPoint - $startPoint; $bit = array( ' year' => $secs / 31556926 % 12, ' month' => $secs / 2592000 % 12, ' day' => $secs / 86400 % 7, ' hour' => $secs / 3600 % 24, ' minute' => $secs / 60 % 60, ' second' => $secs % 60 ); foreach ($bit as $k => $v) { if ($v > 1) $ret[] = $v . $k . 's'; if ($v == 1) $ret[] = $v . $k; } if (!isset($ret)) { $ret[0] = 'few seconds'; } return $ret[0]; }
Use this function, this will give you exact duration between to timestamps. Make sure the start point is in UNIX timestamp format.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Use this function, this will give you exact duration between to timestamps. Make sure the start point is in UNIX timestamp format.