|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
#1
|
|||
|
|||
|
Script: DD Countdown Script II
http://www.dynamicdrive.com/dynamic...dhtmlcount2.htm I have the script working but wanted to implement a certain Time Zone to the countdown. I have something that is going to end on June 6, 2005 23:59:59 EST and did not know how to make the countdown end at the Eastern Standard Time Zone? Thanks in advance. Thomas |
|
#2
|
||||
|
||||
|
Hope you haven't given up yet or your event has passed by the time you see this. Anyways, the script you are using uses the time as set on the user's computer. As is, that will return the time left until the time of your event as if it were occurring locally for the user. For many televised events, this is better than EST, also, by June 6th we may have daylight time to worry about as well. Local time of the user may be daylight or not depending upon convention in his/her zone. If you still want to go for EST, even though it will be EDT by then, I think. You can follow this line in the code:
Code:
var todayh=today.getHours() Code:
if ('number'==typeof today.getUTCHours()){ todayh=today.getUTCHours()-5;todayd=today.getUTCDate();
if (todayh<0) {todayh=todayh+24; todayd=todayd-1;}}
Last edited by jscheuer1; 03-21-2005 at 06:25 AM. Reason: add error checking |
|
#3
|
|||
|
|||
|
Thank You for your help! I will add the new code and see what happens! Thanks again.
PS - I used a -4 since Daylight Savings time is tomorrow night and my event will be in June. Sound ok? |
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
|||
|
|||
|
Quote:
In this instance, Code:
if(today.getUTCHours) {
By the way, constructing strings and using the parse method is a really obtuse way of doing this. Subtracting Date objects directly will result in the same millisecond value and is far more efficient. Code:
function countdown() {
var est = new Date(),
target = new Date(yr, mo, da, hr, min, sec);
est.setUTCHours(est.getUTCHours - 5);
dd = target - est;
/* ... */
}
Mike |
|
#6
|
||||
|
||||
|
Quote:
Added Later, I put your code in where it looked like it went and got: Quote:
Last edited by jscheuer1; 04-02-2005 at 05:17 AM. |
|
#7
|
|||
|
|||
|
Quote:
Code:
est.setUTCHours(est.getUTCHours() - 5); With any of the Date manipulation methods, including the constructor itself, you can supply out-of-range values. When you do, the object will automatically cap the value, but adjust other fields too. For example, setting the 31st of November will result in a date of the 1st of December. Quote:
Quote:
Mike |
|
#8
|
||||
|
||||
|
Nice to know you sometimes mess up, like the rest of us, I was starting to get a complex. Anyways, your new modification makes it better, no NAN's. However, my version and the original version give 71 days to June 12th 2005, your code makes it 101 days. 71 is the correct amount as I type, according to a calendar. Off by a month, probably a simple fix for that.
Last edited by jscheuer1; 04-02-2005 at 05:44 PM. |
|
#9
|
|||
|
|||
|
Quote:
We're all human. I've made plenty of monumental cock-ups in the past, I can assure you. Hopefully, they'll stay in the past.Quote:
Code:
var est = new Date(),
target = new Date(yr, mo - 1, da, hr, min, sec);
|
|
#10
|
||||
|
||||
|
Quote:
Code:
function countdown() {
var est = new Date(),
target = new Date(yr, mo-1, da, hr, min, sec);
est.setUTCHours(est.getUTCHours()+1);
dd = target - est;
Last edited by jscheuer1; 04-02-2005 at 06:31 PM. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|