...

View Full Version : Changing script action from relative to server time



Tom Hogan
08-03-2006, 01:35 AM
I'm running a script with this instruction:


today = new Date()
day = today.getDay()
hr = today.getHours()
min = today.getMinutes()
if(min >= 30)hr +=.5;

Is there a way of manipulating that code so the script action will occur according to the time on the server rather than as it is now?

dtra
08-03-2006, 03:05 AM
well, i'm gonna assume you're using php


day = <?= date('d'); ?>;
hr = <?= date('H'); ?>;
min = <?= date('i'); ?>;
if(min >= 30) {
hr +=.5;
}


that will obviously run once, when the page is loaded, and give you the server time at load

if you want to have the date/time constantly updated from the server, you will prolly need to look into xmlhttprequest i think, but i think once should be enough, you should be able to take the original time, and then just use javascript to change the time

hth
dave



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum