Countdown clock code

I created a countdown clock for a jewel of the day promotion on my website. I’ve had a few people ask for the code, so I figured I would share it with everyone.

I do have one problem with it. The javascript will not display numbers 0 through 9 as 01 through 09. Besides that, it works rather well.

I created a php file which I call.


$Hour = ‘%H’;

$Min = ‘%M’;

$Sec = ‘%S’;

$strfH = strftime($Hour);

$strfM = strftime($Min);

$strfS = strftime($Sec);

$mHour = 23;

$mMin = 59;

$mSec = 59;

$hourClock = $mHour-$strfH;

$minClock = $mMin-$strfM;

$secClock = $mSec-$strfS;


This php file passes variables to the browser. Javascript takes over and uses the variables to display the clock. Here is the javascript code that I wrote:

<input class="clock_input" style="border: 0" type="text" size="8"

Here is the link to the code in action:


If you have any suggestions on padding the single digit numbers, I am more than interested.

I hope this can help someone out,


Thank you for your contribution.