a good place to start in your PHP effort is in lib-custom.php. that's where you will place your function. then you only need to create a block to contain the output.
Text Formatted Code
<?php
/* Works out the time since the entry post, takes a an argument in unix time (seconds) */
function time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
$today = time(); /* Current unix time */
$since = $today - $original;
// $j saves performing the count function each time around the loop
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0) {
// DEBUG print "<!-- It's $name -->n";
break;
}
}
$print = ($count == 1) ? '1 '.$name : "$count {$name}s";
if ($i + 1 < $j) {
// now getting the second item
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
// add second item if it's greater than 0
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
}
}
return $print;
}
?>
.
Text Formatted Code
<?
function elapsed($year, $month, $day, $hour, $minute) {
// No copyright, use and fiddle with as you see fit, just don't steal credit for it,
// as it is based on the work of myself and several other people.
// Call the function with the command elapsed(yyyy,mm,dd,hh,mm), for example:
// elapsed(1974,5,14,06,10) will produce the elapsed time since my birth date.
// This script will automatically omit parts that return a zero value, so that 1 year,
// 3 months, 0 days, 0 hours and 0 minutes will not show the days, hours and minutes,
// as that would be quite pointless and ugly.
$todayMonth = date(n);
$todayDay = date(j);
$todayHour = date(G);
$todayMinute = date(i);
$monthday = date(nj);
$link = $month.$day;
$datepoint = $link;
if ($monthday < $datepoint) $years = date(Y) - $year - 1;
else $years = date(Y) - $year;
if ($years < 1) $yearWord = '';
elseif ($years == 1) $yearWord = 'year,';
elseif ($years > 1) $yearWord = 'years,';
if ($todayMonth > $month) {
if ($todayDay < $day) $months = $todayMonth - $month -1;
else $months = $todayMonth - $month;
} else {
$between = $month - $todayMonth;
$plus = 12 - $month;
if ($todayDay < $day) $months = $month + $plus - $between -1;
else $months = $month + $plus - $between;
}
if ($months == 1) $monthWord = 'month,';
elseif ($months > 1) $monthWord = 'months,';
if ($todayDay > $day) {
if ($todayHour < $hour) $days = $todayDay - $day -1;
else $days = $todayDay - $day;
} else {
$between = $day - $todayDay;
$daysToEndOfMonth = date(t) - $day;
if (date(t) == 28) $plus = $daysToEndOfMonth;
if (date(t) == 29) $plus = $daysToEndOfMonth;
if (date(t) == 30) $plus = $daysToEndOfMonth;
if (date(t) == 31) $plus = $daysToEndOfMonth;
if ($todayHour < $hour) $days = $day + $plus - $between - 1;
else $days = $day + $plus - $between;
}
if ($days == 1) $dayWord = 'day,';
else $dayWord = 'days,';
if ($todayHour > $hour) {
if ($todayMinute < $minute) $hours = $todayHour - $hour - 1;
else $hours = $todayHour - $hour;
} else { $between = $hour - $todayHour;
$plus = 24 - $hour;
if ($todayMinute < $minute) $hours = $hour + $plus - $between - 1;
else $hours = $hour + $plus - $between;
}
if ($hours == 1) $hourWord = 'hour,';
if ($hours > 1) $hourWord = 'hours,';
if ($todayMinute > $minute) {
$minutes = $todayMinute - $minute;
} else { $between = $minute - $todayMinute;
$plus = 60 - $minute;
$minutes = $minute + $plus - $between;
}
if ($minutes == 60) $minutes = 0;
if ($minutes == 1) $minuteWord = 'minute';
elseif ($minutes > 1) $minuteWord = 'minutes';
if ($years == 0) { $years = ''; $yearWord = ''; }
if ($months == 0) { $months = ''; $monthWord = ''; }
if ($days == 0) { $days = ''; $dayWord = ''; }
if ($hours == 0) { $hours = ''; $hourWord = ''; }
if ($minutes == 0) { $minutes = ''; $minuteWord = ''; }
echo $years.' '.$yearWord.' '.$months.' '.$monthWord.' '.$days.' '.$dayWord.' '.$hours.' '.$hourWord.' '.$minutes.' '.$minuteWord.'';
}
?>
lots of these around the net. hope that helps.