Jump to content
xisto Community
Supa Comix

Counting Down To A Time php or java?

Recommended Posts

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

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 website
3 ForeColor - Whatever colour you want your text, this is it!
4 CountActive - Whether the timer is counting down or not
5 CountStepper - How much to count down each time (make time faster by increasing this value :blink:) 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

P.S If you want to, search on google for javascript countdown timers, theres heaps of websites and most of them should have explanations.
Edited by Jimmy89 (see edit history)

Share this post

Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.