php Countdown to next Ubuntu Release

By | September 28, 2013

As a incarnated UBUNTU FAN I made my own php based countdown to the next release.

It consists of a single php file with custom made images for the actual numbers and “days”.

You can use the code for your own pleasure as is and without warranty ;)

This code has been updated ;)   and bugfixes have been made.

<?php

$date = strtotime(“October 17, 2013 2:00 PM”);
$remaining = $date – time();

$days_remaining = floor($remaining / 86400);

// If somebody wants to count hours as well.
//$hours_remaining = floor(($remaining % 86400) / 3600);

//$days_remaining into single digits

if ($days_remaining > 99) {

$digit_1 = substr($days_remaining, -3,1);
$digit_2 = substr($days_remaining, -2,1);
$digit_3 = substr($days_remaining, -1);
//convert single digits into img readout
echo “UBUNTU 13.10 RELEASE <br>”;
echo ‘<img src=”‘.$digit_1.’.png” /><img src=”‘.$digit_2.’.png” /><img src=”‘.$digit_3.’.png” /><img src=”days.png” />’;
}

elseif ($days_remaining > 9)
{
$digit_1 = 0;
$digit_2 = substr($days_remaining, -2,1);
$digit_3 = substr($days_remaining, -1);
//convert single digits into img readout
echo “UBUNTU 13.10 RELEASE <br>”;
echo ‘<img src=”‘.$digit_1.’.png” /><img src=”‘.$digit_2.’.png” /><img src=”‘.$digit_3.’.png” /><img src=”days.png” />’;
}
elseif ($days_remaining > 0)
{
$digit_1 = 0;
$digit_2 = 0;
$digit_3 = substr($days_remaining, -1);
//convert single digits into img readout
echo “UBUNTU 13.10 RELEASE <br>”;

echo ‘<img src=”‘.$digit_1.’.png” /><img src=”‘.$digit_2.’.png” /><img src=”‘.$digit_3.’.png” /><img src=”days.png” />’;
}
elseif ($days_remaining = 0)
{
echo “FINALLY UBUNTU 13.10 released today”;
}

?>

DOWNLOAD the source code including images in zip format:  countdown

You are free to enhance and customize this code. Post links to your own creations down below ;)

By the way…. the countdown down below is implemented through the “PHP Code” wordpress plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *