PDA

View Full Version : UTC Time



coolcamo8642
Sep 6th, 2007, 04:35 AM
I currently use two countdown scripts, both of which use the time from the client's computer to generate the time remaining. I would like for the script to instead get UTC time and then subtract five hours (for EST). The point is to display the same time remaining regardless of the user's timezone/time/date.

Here are the beginnings of each script:


dateFuture = new Date(2008,7,21,8,25,00);

function GetCount(){

dateNow = new Date();
amount = dateFuture.getTime() - dateNow.getTime();
delete dateNow;



function clock() {
if (!document.layers && !document.all) return;
var hex = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
var ticktock = new Date();
var month = ticktock.getMonth()+1;
var date = ticktock.getDate();
var day = ticktock.getDay();
var year = ticktock.getFullYear();
var utime = ticktock.getTime();
var hours = ticktock.getHours();
var minutes = ticktock.getMinutes();
var seconds = ticktock.getSeconds();

//Countdown
var cyear = 2008;
var cmonth = 7;
var cdate = 21;
var chours = 8;
var cminutes = 25;
var cseconds = 0;
var cms = 0;

var description = "";
var future = new Date(cyear,cmonth,cdate,chours,cminutes,cseconds,cms);
var future2 = future.getTime();
countdown = future - utime;


Any help would be much appreciated. Every time I try to fix this timezone issue the scripts either stop working or work displaying the wrong amount of time remaining.

Thanks in advance!

Philip M
Sep 6th, 2007, 08:38 AM
var hours = ticktock.getUTCHours();
var ESTHours = hours - 5;
if (ESTHours < 0) {ESTHours = ESTHours +24)};


BTW, the time to say "thanks" is afterwards, not before when the word "please" is usually considered polite. If you find this response helpful then please use the "Thank You For This Post" button.