Counting Down To A Time - php or java?

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting

Counting Down To A Time - php or java?

Supa Comix
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 as

function countdown($days, $hours, $minutes, $seconds){

}

Thanks

Reply

Jimmy89
I am assuming, by Java, you meant JavaScript - which would be a much easier alternative.

I copied this code from http://www.hashemian.com
CODE
<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 tongue.gif) 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
CODE
<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
-jimmy

P.S If you want to, search on google for javascript countdown timers, theres heaps of websites and most of them should have explanations.

 

 

 


Reply

Supa Comix
ace. Thanks that is exactly what im looking for. Thanks a bunch biggrin.gif

Reply

Supa Comix
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); ?>; ?

Reply

Supa Comix
erm if anyone knows the answer to this then please answer biggrin.gif

Reply

pyost
If $date and $time are properly formed, there should be no problems.

Reply

iGuest
How can I "center" the display message & finish message in the countdown timer? Thanks.

-reply by kevin moore

Reply

Jared
QUOTE(FeedBacker @ Mar 9 2008, 01:36 PM) *
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?

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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php count time - 18.87 hr back. (1)
  2. java countdown timer code - 153.86 hr back. (1)
  3. php refresh count time - 207.77 hr back. (1)
Similar Topics

Keywords : counting, time, php, java,

  1. What Scripting Language?
    Java/Python/Ruby? (2)


      Looking for counting, time, php, java,

Searching Video's for counting, time, php, java,
advertisement




Counting Down To A Time - php or java?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE