Jump to content

Custom Countdown Timer(Special)


ajsuk

Recommended Posts

Hey there, me again with another request.  :)

I'd like to build a special custom countdown timer. What makes it special (and more complicated :() is its not going to countdown to a specified event(time,date) as the 100's of other scripts out there do.

Heres what i'd like it to do...

Have 4 cycles of 4.5 Days(108 hours)
Display how long it is to each new cycle start. - For example "2 Days, 8 hours and 5minutes until cycle#3"
Somehow be able to reset/calibrate/specify the countdown and cycle if the webserver went down or something.
This is continues btw... (except if the server goes down ofcourse;))
I think thats everything...  :o

I'm guessing PHP is the way to go with this as we could still use the server to count with?
Thanks a bunch for any help you can give! This ones kicking my backside.  :D
Link to comment
Share on other sites

<?php

function formatetimestamp($until){

  $now = time();
  $difference = $until - $now;

  $days = floor($difference/86400);
  $difference = $difference - ($days*86400);

  $hours = floor($difference/3600);
  $difference = $difference - ($hours*3600);

  $minutes = floor($difference/60);
  $difference = $difference - ($minutes*60);

  $seconds = $difference;
  $output = "You have to wait $days Days, $hours Hours, $minutes Minutes and $seconds Seconds until this Day.";

  return $output;

}

//int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )

echo  formatetimestamp(mktime(0,0,0,12,31,2006)); //output: e.g "You have to wait 162 Days, 4 Hours, 38 Minutes and 46 Seconds until this Day"


?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.