Jump to content


Photo

Custom Countdown Timer(Special)


  • Please log in to reply
4 replies to this topic

#1 ajsuk

ajsuk
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 16 August 2006 - 03:20 PM

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

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 16 August 2006 - 03:29 PM

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.

#3 ajsuk

ajsuk
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 16 August 2006 - 03:36 PM

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. :)

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 16 August 2006 - 03:50 PM

<?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"


?>

#5 ajsuk

ajsuk
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 16 August 2006 - 06:11 PM

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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users