Skip to content

Instantly share code, notes, and snippets.

@MSeven
Created July 17, 2009 11:06
Show Gist options
  • Save MSeven/149003 to your computer and use it in GitHub Desktop.
Save MSeven/149003 to your computer and use it in GitHub Desktop.
<?php
function timeAgo($difference) {
static $timeConf = array(
'Seconds' => 60,
'Minutes' => 60,
'Hours' => 24,
'Days' => 0
);
$result = array();
foreach ($timeConf as $key => $value) {
if ($value == 0) {
$result[$key] = $difference;
} else {
if ($difference >= $value) {
$result[$key] = $difference % $value;
} else {
$result[$key] = $difference;
}
$difference = intval(floor($difference / $value));
}
}
return ($result);
}
echo (TimeAgo(1243443));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment