Countdown Block

Mods etc.

Moderator: Integra Moderator

Re: Countdown Block

PostAuthor: IntegraMOD » Wed Nov 22, 2006 9:54 pm

"evolver";p="17860" wrote:57 replies for a countdown block, whaw...

I have been watching this topic with interest, but I see you struggling with the timezones...
Very logical, if you are using PHP to read the time because PHP doesn't read the usertime, only the servertime.
So the only way to get it right for every user by PHP would be by timezonecalculation for every user...
All this is unnecessary...

Javascript is better for this situation, and I use one...
Different from PHP, javascript will use the visitors computertime instead of servertime...
No need for special formulas to make it suitable with different timezones, and it will save your server some processing too...
...and with no extra tables to add in your database...


Can't be more easy than this:
Just make a block with HTML and place this code in it:

(It's javascript, so I've placed it as a downloadable compressed textfile)

The only problem would be language, if you have more languages on your forum.


This is a great idea just a question though.....
In the script it has the following.
Code: Select all
countdownTo=new Date(31-12-2006);countdownTo.setYear(2006);countdownTo.setMonth(12);countdownTo.setDate(02);countdownTo.setHours(00);countdownTo.setMinutes(00);countdownTo.setSeconds(0);  

This will give us a countdown till the new year but why is the date set to "02" I have replaced it with "31" which is the date I want it to countdown to and it then shows the wrong time left.

I have done a little research and come up with the following.

Be wary of the month input for your Date definition, however, as the Date object uses month values of 0 to 11 and not 1 to 12 as you may be used to.

So if we take this into consideration and set the month to "0" for January and the date to "01" then the countdown also shows the correct time left.

So with this it would be better to use the correct date and just always remember to -1 form the month you are counting down to.

This would then give us....
Code: Select all
countdownTo=new Date(01-01-2007);countdownTo.setYear(2007);countdownTo.setMonth(0);countdownTo.setDate(01);countdownTo.setHours(00);countdownTo.setMinutes(00);countdownTo.setSeconds(0);  


Have I got this correct or am I completely off track here <img>
Last edited by IntegraMOD on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
Image
Please do not PM for support
User avatar
IntegraMOD
Administrator
Administrator
 
Posts: 459
Likes: 0 post
Liked in: 0 post
Joined: Sat Mar 11, 2006 3:46 pm
Cash on hand: 0.00
Bank: 100.00
Location: Seattle Wa

Re: Countdown Block

PostAuthor: evolver » Thu Nov 23, 2006 2:39 am

[quote=""gffb";p="17864""]This would then give us....
Code: Select all
countdownTo=new Date(01-01-2007);countdownTo.setYear(2007);countdownTo.setMonth(0);countdownTo.setDate(01);countdownTo.setHours(00);countdownTo.setMinutes(00);countdownTo.setSeconds(0);  


Have I got this correct or am I completely off track here <img>

You can compare your countdown with this:
http://www.timeanddate.com/
Last edited by evolver on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
ImageAlways remember you're unique, just like everyone else.
We are born naked, wet and hungry. Then things get worse.
Don't take life too seriously, you won't get out alive.
User avatar
evolver
Sr Integra Member
Sr Integra Member
 
Posts: 420
Likes: 0 post
Liked in: 0 post
Joined: Mon Mar 27, 2006 12:46 pm
Cash on hand: 0.00
Location: Oostende

Re: Countdown Block

PostAuthor: krillmeed » Thu Dec 14, 2006 1:26 pm

This is a good mod went in of course first time, but here is a list of problems i have with it:
1: When i switch on the title bar in the blocks management for this, it pushes out so much it is totally out of line with the others.
2. i know this was for the integramod 2 template, but a lot of my templates are black backgrounds and white fonts, how do i change the countdown title to a white fonts. All the other blocks seem to do this naturally.
3: It will go on the index page but only as a header, unless you put it only on the portal which does look good as a centre block, it will not be shown at all on the index page. When i do put it on the index page as a header, it once again stretches the whole block out. Unlike the rest. I have seen this done on one site, a little tight but at least it is possible to keep all the options open to us in the same width block in a header as all the rest. Any help would be appreciated, with Christmas & New year coming up this would be a nice mod to have. <img>
Last edited by krillmeed on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

krillmeed
Sr Integra Member
Sr Integra Member
 
Posts: 301
Likes: 0 post
Liked in: 0 post
Joined: Sat May 27, 2006 12:34 am
Cash on hand: 0.00

Previous

Return to IntegraMOD Modifications

Who is online

Registered users: Google [Bot], Helter, Majestic-12 [Bot]