Duration.php

I wanted to display the age, in years, months, days, etc., of my old weblog entries.

duration.png

I found Aidan Lister’s Duration.php. It defines a static method to convert a timestamp into a readable string.

// 2 hours, 20 minutes, 5 seconds
$time = 60*60*2 + 20*60 + 5;

// Convert to a string
echo Duration::toString($time);
echo "\n";

Useful. Thanks Aidan.

More like this: .

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*