Number of days left until 07.07.07


According to my google analytics account, the most popular google search that brings people to my website is “days left until 07.07.07“. I found this interesting and also quite funny since I only put this information in our wedding section to inform people of the time left before my wedding. Regardless, I thought I could share the script I wrote/edited in order to find the famous countdown.

Of course, there are many other ways to implement this. For example, I could use javascript to update the time every minutes (or seconds) without reloading the page, however I chose a server-side language so that the outcome is independent of the viewer’s setting (Javascript on/off).

<?php
 function countdown($yr, $month, $day, $hr, $min){
 // make a unix timestamp for the given date
 $countdown = mktime($hr, $min, 0, $month, $day, $yr, -1);

 // get current unix timestamp
 $today = time();

 // get the number of minutes between the times
 $diff = $countdown - $today;

 // Make sure the date is not passed already
 if ($diff 

To use the function, you simply call it using


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s