WordPress.org

Support

Support » Themes and Templates » How many days ago a post is posted

How many days ago a post is posted

  • I am working on my new theme and for any post I would like to include the number of days ago that post has been posted, like at garrettdimon.com. I did something similar on my site but it does give me some strange numbers. The code I am using is

    $date1 = strtotime(date('d-m-y'));
    $date2 = strtotime(the_date('d-m-y', '', '', false));
    $total_days = round(($date1-$date2)/(24*3600));
    echo $total_days." days old";

    Any clue?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How many days ago a post is posted’ is closed to new replies.