How to Add a Running Total of Years and Days You’ve Blogged

Blogging for over 4 years. That’s me. I added a running total to the bottom of the blog.

I noticed Ben had the number of days he’d been blogging on the bottom of his blog and asked how he did it. He had a single line of php that he got from Jonathan Snook:

< ?= round( (time() - strtotime('November 1 2005')) / 60 / 60 / 24);?>

That worked, but it was way too many days for me so I added a little more php.

Here’s what I put in the footer of my pages: (The date is the date of my first post)

Blogging for < ? $days = round( (time() - strtotime('October 28th, 2002')) / 60 / 60 / 24 ); $years = round($days/ 356); $daysLeft = $days - ($years * 365); print "$years years and $daysLeft days"; ?>

Four years and 36 days. Crazy. And this post 1406 according my WordPress dashboard.

5 thoughts on “How to Add a Running Total of Years and Days You’ve Blogged”

  1. You have to put it in a template, not just a blog entry. And this is for WordPress, which is PHP based. If you were using Moveable Type it probably wouldn’t work because MT is perl based.

Comments are closed.