function hosting_format_interval in Hosting 6.2
Same name and namespace in other branches
- 5 hosting.module \hosting_format_interval()
- 7.4 hosting.inc \hosting_format_interval()
- 7.3 hosting.inc \hosting_format_interval()
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 cron/
hosting_cron.module - Implementation of hook_nodeapi().
- hosting_platform_listing in platform/
hosting_platform.module - Simple list for top level navigation.
- hosting_platform_view in platform/
hosting_platform.module - Implementation of hook_view().
- hosting_queues_configure in ./
hosting.module - Form to configure the frequency of queue execution.
- hosting_queue_summary_block in ./
hosting.module - Build a block summarising the hosting queues.
File
- ./
hosting.inc, line 85 - 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),
));
}