The Puke Clock

I hereby declare that Shaun Micallef’s new show, NEWStopia is fantastic. I have been watching it myself “on the wire” and decree it to be great.

When I was sick on the weekend, I was telling Godfrey about it. Those who know Godfrey well will know that he’s probably more knowledgeable in the field of paranoid pharmacology than a lot of doctors, and is usually a good source of info when you’re not feeling great as to what over-the-counter medicines pack the most bang for buck.

Anyway, in describing my symptoms, one of which had been vomiting, Godfrey made an off-hand remark that I had “better reset to puke clock”.

This is something our group of friends has known about for some time - essentially the “puke clock” keeps track of how long it has been since you last vomited. Usually it’s in the head of each person, but I got thinking that my brain real estate is too valuable to waste on such trivia, and PHP might be the best way to track it.

And if I learnt something PHP-related, which while once a hobby is becoming more and more work-related, it would be a useful exercise.

The time() function in PHP returns the current time, measured in the number of seconds since January 1 1970 00:00:00 GMT, which is known as the Unix Epoch. Apparently, according to Wikipedia, when Unix time passed 1,000,000,000 seconds on the 09-Sep-01, there was a huge party in Copenhagen, Denmark to celebrate. Pretty fun stuff.

I recall that I puked pretty soon after typing last blog entry, which mentions that it was 3:20am at the time of writing, so I’m going to assume that my puke clock start date is 22-Oct-07, 03:30:00am. 1223609400 in Unix Time, according to http://www.onlineconversion.com/unix_time.htm which is wrong. Presumably they have an error in their conversion forward, because other sites like http://soft.zoneo.net/Unixtime/index.php and http://www.epochconverter.com/ (and even http://www.onlineconversion.com/unix_time.htm’s backward conversion) agree that it should be 1193023800.

I can find the current unix time pretty easily, using time(). Subtract the puke time from this, and you get the difference in seconds. At the time of writing I get a value of 266,000 seconds, approximately.

Then I did some fairly simple maths, like 1 year is 31556926 seconds, 1 month is 2629743 seconds, and so on. Whip in a meta-refresh tag for reloading the page every 10 seconds, and the net result can be enjoyed by all here:
http://www.chuckler.org/pukeclock.php.

Note that this code isn’t at all optimised, and is very longwinded. If you wanted to do this properly, you would probably write a function for the calculations, which are pretty well all the same, and save code.