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

by Ron on December 1, 2006 · 4 comments

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.

{ 4 comments… read them below or add one }

Linoge 12.03.06 at 9:59 pm

So copy-pasting that into my blog gets me… well… that - the code, but no output. What am I doing wrong?

Ron 12.04.06 at 9:34 am

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.

Linoge 12.04.06 at 9:36 pm

Oh. Now I feel stupid.

Ron 12.04.06 at 9:43 pm

No need to feel stupid. I should have mentioned the system requirements :)

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Older post: Cheap Angel

Newer post: Silly String to Detect Trip Wires