Using ago time format is more appealing than using standard date/time format. You can easily catch the attention of people of you will say “posted 1hour ago” rather than saying “posted on Feb 2”. Users can easily recognize how fresh a post or article is by using the ago time format which will attract them to click and read your post.

This short PHP function will return the ago time format by supplying the actual date/time of a post or article. This function can also be applied into some CMS like WordPress.

function ywt_time_ago($time) {
    $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
    $lengths = array("60","60","24","7","4.35","12","10");

    $now = time();

    $difference     = $now - strtotime($time);
    $tense         = "ago";

    for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
        $difference /= $lengths[$j];
    }

    $difference = round($difference);

    if($difference != 1) {
        $periods[$j].= "s";
    }

    return "$difference $periods[$j] ago";
}

How to Use

To use the function, you can easily call it and supply with actual date and time of the post. In my example below, i used ISO 8601 full date/time format.

<?php echo ywt_time_ago('2013-02-12T15:19:21+00:00'); ?>

A Note for Time Zones

The script above will only work properly if both the server time zone and the website time zone is the same otherwise a fix will be needed.

How to take Cialis it seems to me that would already be time to cease to discuss this question. As I already answered it not once. Have it in a look. You shouldn’t worry! All deer go south when they are called by homesickness. Are turned and lie on snow till some hours.