/    Sign up×
Community /Pin to ProfileBookmark

a daily counter

Hi, I want to make a counter just like the one below for a web page, this counter is from play.com which counts down everyday.

[IMG]http://img10.imageshack.us/img10/3226/countime.png[/IMG]

I’ve been searching for few days and found that javascript will work but it will have to rely on the time that’s been set on the pc, and so I doubt that they’ve used this method.
I also doubt that they’ve made it by flash as I can still view it without having flash installed.

Is it possible that they’ve used php to make it? I understand that php has to be constantly refreshed to increment every digit of the counter, but this counter is only daily and has to be refreshed anyway, in order to see the day change on the counter.
Is it also possible that they’ve used an image that changes daily, rather than using text digits?

Im still trying to understand all the different types of scripts that are available to a web designer so if you think ive missed any scripts out that can make a counter please let me know, thanks

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@criterion9Jun 16.2010 — Chances are they are using PHP to find the offset between the date in question and today's date (as returned by the server). Then on the client side a script (Javascript/Flash/what have you) is updating the display on an increment.
Copy linkTweet thisAlerts:
@fracture125authorJun 16.2010 — Chances are they are using PHP to find the offset between the date in question and today's date (as returned by the server). Then on the client side a script (Javascript/Flash/what have you) is updating the display on an increment.[/QUOTE]

thanks, i really appreciate it.

i think im understanding what you've said. do you know of any tutorials that will teach you how write this kind of php script? that gathers the dates from the server, and corresponse to the javascript.
Copy linkTweet thisAlerts:
@criterion9Jun 16.2010 — http://php.net/manual/en/function.date.php

You can easily pass content from php to javascript
[code=html]
<script type="text/javascript">
var myVar = "<?php echo $myVar; ?>";
alert(myVar);
</script>
[/code]
Copy linkTweet thisAlerts:
@fracture125authorJun 16.2010 — http://php.net/manual/en/function.date.php

You can easily pass content from php to javascript
[code=html]
<script type="text/javascript">
var myVar = "<?php echo $myVar; ?>";
alert(myVar);
</script>
[/code]
[/QUOTE]


thanks, i'll check them out.
Copy linkTweet thisAlerts:
@fracture125authorJun 16.2010 — http://php.net/manual/en/function.date.php

You can easily pass content from php to javascript
[code=html]
<script type="text/javascript">
var myVar = "<?php echo $myVar; ?>";
alert(myVar);
</script>
[/code]
[/QUOTE]




Ok so ive had a look at a few more scripts and I think ive understood the concept a lot more than before. I just want to clarify to see if I understood what you’ve said.

I should start off by creating the javascript, this will make the daily countdown of how many days left.

And then create a php code within the javacript code to find the present date, and it will find this date by getting it from the server.

without the php code, the code from the javascript would get the present date from the user’s pc, is this correct?

How does the code know not to look for the date from the users pc? Will I need to put some javascript code in so it will ignore getting the code from the users pc and look straight to the php code to get the date from the server?

Thanks.
Copy linkTweet thisAlerts:
@criterion9Jun 16.2010 — I'm suggesting you create javascript code to update the display (usually this is only required if the display includes seconds or minutes). Then for the "current date" it just uses the information provided by the PHP in the variable as illustrated before.
Copy linkTweet thisAlerts:
@fracture125authorJun 16.2010 — I'm suggesting you create javascript code to update the display (usually this is only required if the display includes seconds or minutes). Then for the "current date" it just uses the information provided by the PHP in the variable as illustrated before.[/QUOTE]

sorry if i seem to not be getting this as quick as i probably should be, im quite new to scripting.

what did you mean by (as returned by the server)?

does the current date and date in question get typed into the php?

does the date in question mean the future date?

thanks
Copy linkTweet thisAlerts:
@criterion9Jun 16.2010 — what did you mean by (as returned by the server)?[/quote]
As shown in the example above you can pass a variable created in PHP to a variable used in your Javascript
does the current date and date in question get typed into the php?[/quote]
Yes, or pulled from a database or file or wherever.
does the date in question mean the future date? [/quote]
Yes.
Copy linkTweet thisAlerts:
@fracture125authorJun 16.2010 — As shown in the example above you can pass a variable created in PHP to a variable used in your Javascript

Yes, or pulled from a database or file or wherever.

Yes.[/QUOTE]


that&#8217;s excellent thanks, i dont now how to code myself, so i'll keep looking around to find a script. But thanks for being patient and helping me out understand the way both of the scripts work, thanks
Copy linkTweet thisAlerts:
@criterion9Jun 16.2010 — No problem. Glad I could help. ?
×

Success!

Help @fracture125 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...