function hosting_format_interval in Hostmaster (Aegir) 6
Format a timestamp as a string in a friendly way.
Parameters
$ts: The timestamp to format as a an interval.
Return value
Returns a string representing the given timestamp:
- If the timestamp is the current time: 'Now'.
- If the timestamp is 0 or FALSE: 'Never'
- Otherwise formatted as 'X ago' where 'X' is for example 1 year or 1 minute etc.
See also
8 calls to hosting_format_interval()
- hosting_cron_nodeapi in modules/
hosting/ cron/ hosting_cron.module - Implementation of hook_nodeapi().
- hosting_platform_listing in modules/
hosting/ platform/ hosting_platform.module - Simple list for top level navigation.
- hosting_platform_view in modules/
hosting/ platform/ hosting_platform.module - Implementation of hook_view().
- hosting_queues_configure in modules/
hosting/ hosting.module - Form to configure the frequency of queue execution.
- hosting_queue_summary_block in modules/
hosting/ hosting.module - Build a block summarising the hosting queues.
File
- modules/
hosting/ hosting.inc, line 51 - General purpose Hosting module functions.
Code
function hosting_format_interval($ts) {
if ($ts == time()) {
return t('Now');
}
if (!$ts) {
//Treats the UNIX EPOCH as never.
return t('Never');
}
return t("@interval ago", array(
"@interval" => format_interval(time() - $ts, 1),
));
}