Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Counting Down To A Time, php or java?
Supa Comix
post Aug 26 2007, 04:36 PM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 9-August 07
Member No.: 23,954



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
Go to the top of the page
 
+Quote Post
Jimmy89
post Aug 27 2007, 10:50 AM
Post #2


Living at the Datacenter
Group Icon

Group: [HOSTED]
Posts: 696
Joined: 30-June 06
From: Australia
Member No.: 14,219



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.

This post has been edited by Jimmy89: Aug 27 2007, 10:51 AM
Go to the top of the page
 
+Quote Post
Supa Comix
post Aug 27 2007, 01:12 PM
Post #3


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 9-August 07
Member No.: 23,954



ace. Thanks that is exactly what im looking for. Thanks a bunch biggrin.gif
Go to the top of the page
 
+Quote Post
Supa Comix
post Aug 27 2007, 04:13 PM
Post #4


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 9-August 07
Member No.: 23,954



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); ?>; ?
Go to the top of the page
 
+Quote Post
Supa Comix
post Oct 15 2007, 04:50 PM
Post #5


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 9-August 07
Member No.: 23,954



erm if anyone knows the answer to this then please answer biggrin.gif
Go to the top of the page
 
+Quote Post
pyost
post Oct 15 2007, 06:44 PM
Post #6


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 993
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



If $date and $time are properly formed, there should be no problems.
Go to the top of the page
 
+Quote Post
Feedbacker
post Mar 9 2008, 07:36 PM
Post #7


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



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

-reply by kevin moore
Go to the top of the page
 
+Quote Post
Jared
post Apr 21 2008, 02:07 AM
Post #8


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 40
Joined: 17-April 08
Member No.: 29,853



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>
Go to the top of the page
 
+Quote Post

Fast ReplyReply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. What Scripting Language?(2)


 



- Lo-Fi Version Time is now: 7th July 2008 - 01:48 AM