- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
<?php $ago = time()-$time; ?>
<?php $hour = sfConfig::get('app_hour_in_seconds'); ?>
<?php $day = sfConfig::get('app_day_in_seconds'); ?>
<?php if($ago < 60): ?>
<span>less than one minute ago</span>
<?php elseif($ago < $hour): ?>
<?php $m = floor($ago/60); ?>
<span><?php echo($m); ?> minute<?php echo(($m > 1 ? 's' :'')); ?> ago</span>
<?php elseif($ago <= $day): ?>
<?php $h = floor($ago/$hour); ?>
<span><?php echo($h); ?> hour<?php echo(($h > 1 ? 's' :'')); ?> ago</span>
<?php elseif ($ago <= $day*30): ?>
<?php $d = floor($ago/$day); ?>
<span><?php echo($d); ?> day<?php echo(($d > 1 ? 's' :'')); ?> ago</span>
<?php elseif ($ago <= $day*365): ?>
<?php $m = floor($ago/$day*30); ?>
<?php $d = floor(($ago-$m)/$day); ?>
<span><?php echo($m); ?> month<?php echo(($m > 1 ? 's' :'')); ?> <?php echo($d); ?> day<?php echo(($d > 1 ? 's' :'')); ?> ago</span>
<?php else: ?>
<?php $y = floor($ago/$day*365); ?>
<?php $m = floor(($ago-$y)/$day*30); ?>
<?php $d = floor(($ago-$y-$m)/$day); ?>
<span><?php echo($y); ?> year<?php echo(($y > 1 ? 's' :'')); ?>
<?php echo($m); ?> month<?php echo(($m > 1 ? 's' :'')); ?>
<?php echo($d); ?> day<?php echo(($d > 1 ? 's' :'')); ?> ago</span>
<?php endif; ?>