function activity_format_offset in Activity 6
Same name and namespace in other branches
- 5.4 activity.module \activity_format_offset()
- 5.2 activity.module \activity_format_offset()
- 5.3 activity.module \activity_format_offset()
Custom date formatter to the display a human language formatted string expressing how long ago this occured.
Parameters
$timestamp : The unix timestamp() of when an activity occurred.
File
- ./
activity.module, line 1096 - activity.module
Code
function activity_format_offset($timestamp) {
$offset = strftime("%j") + strftime("%Y") * 365 - (strftime("%j", $timestamp) + strftime("%Y", $timestamp) * 365);
if ($offset >= 7) {
$offset = strftime("%V") + strftime("%Y") * 52 - (strftime("%V", $timestamp) + strftime("%Y", $timestamp) * 52);
$end = $offset != 0 ? format_plural($offset, t("a week ago"), t("@count weeks ago", array(
"@count" => $offset,
))) : t("Today");
}
else {
if ($offset > 0) {
$end = format_plural($offset, t('Yesterday'), t('@count days ago', array(
'@count' => $offset,
)));
}
else {
$end = t('Today');
}
}
return $end;
}