Supa Comix 0 Report post Posted August 26, 2007 Hey i have been searching google and websites to find the answer to my question but i just get blasted with a bunch of code that isn't explained... So i would like to know how, in either php or java how i would get something to count down to a certain time, but not specifically a time, more like count down in days, hours, minutes and seconds and not require a refresh... like it count downs on the page every second... And that i can specify the days, hours etc in the start of the function such asfunction countdown($days, $hours, $minutes, $seconds){}Thanks Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 27, 2007 (edited) I am assuming, by Java, you meant JavaScript - which would be a much easier alternative.I copied this code from http://www.hashemian.com/ <script language="JavaScript">TargetDate = "12/31/2020 5:00 AM";BackColor = "palegreen";ForeColor = "navy";CountActive = true;CountStepper = -1;LeadingZero = true;DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";FinishMessage = "It is finally here!";</script><script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> As you said, you've been blasted with heaps of code without explanations - so I'll explain this for you.1 TargetDate - This is the date (and time) that you are counting down too!2 BackColor - This is for the graphical side of it, change this to match your website3 ForeColor - Whatever colour you want your text, this is it!4 CountActive - Whether the timer is counting down or not5 CountStepper - How much to count down each time (make time faster by increasing this value ) best to leave this one!6 LeadingZero - Display zero in front of values (e.g. 04 days left)7 DisplayFormat - How the values will be displayed, change to whatever suits you!8 FinishMessage - This is what is displayed when the countdown is finished!the very last line<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>tells the browser where to look for the javascript file. If you want, you can download this file and host it locally (with your website) and change the address as necessary.Good Luck-jimmyP.S If you want to, search on google for javascript countdown timers, theres heaps of websites and most of them should have explanations. Edited August 27, 2007 by Jimmy89 (see edit history) Share this post Link to post Share on other sites
Supa Comix 0 Report post Posted August 27, 2007 ace. Thanks that is exactly what im looking for. Thanks a bunch Share this post Link to post Share on other sites
Supa Comix 0 Report post Posted August 27, 2007 One last question. Say if i was recalling a date and time variable from a mysql database using php, in order to set the time could i just set the time Targetdate = <?php echo($date . $time); ?>; ? Share this post Link to post Share on other sites
Supa Comix 0 Report post Posted October 15, 2007 erm if anyone knows the answer to this then please answer Share this post Link to post Share on other sites
pyost 0 Report post Posted October 15, 2007 If $date and $time are properly formed, there should be no problems. Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 9, 2008 How can I "center" the display message & finish message in the countdown timer? Thanks. -reply by kevin moore Share this post Link to post Share on other sites
Jared 0 Report post Posted April 21, 2008 How can I "center" the display message & finish message in the countdown timer? Thanks. -reply by kevin moore Is this what you're looking for?<body style="margin: 32pt;"><center style="font-family: tahoma; font-size: 8pt;"><script language="JavaScript">TargetDate = "12/31/2020 5:00 AM";BackColor = "white";ForeColor = "midnightblue";CountActive = true;CountStepper = -1;LeadingZero = true;DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds";FinishMessage = "It is finally here!";</script><script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script></center></body> Share this post Link to post Share on other sites
iGuest 3 Report post Posted May 15, 2010 that's all cool & great js countdown, thank you very much for sharing.-reply by JavaScript Countdown Timer Share this post Link to post Share on other sites