Skip to content

Instantly share code, notes, and snippets.

@DennisRas
DennisRas / time_ago.php
Created August 26, 2011 14:24
My suggestion for a time function
<?php
if ( ! function_exists('time_ago'))
{
function time_ago($time, $max_units = NULL)
{
$lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
$units = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
$unit_string_array = array();