Jump to content

Archived

This topic is now archived and is closed to further replies.

ajsuk

Custom Countdown Timer(Special)

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

Share this post


Link to post
Share on other sites
Any sort of counter would be best implimented in javascript. Php runs on the server so you'd need to do a page refresh every second.

Share this post


Link to post
Share on other sites
Good point, I should of mentioned I don't care about it really acting as a live counter, just giving a static output when the page has been loaded would be fine. :)

Share this post


Link to post
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"


?>

Share this post


Link to post
Share on other sites
This looks like one of the many standard countdown scripts for a specific date. (New year for example)
Doesn't do what I'd like...

Share this post


Link to post
Share on other sites

×

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.