Server Side: Time Zones
started by Dave_smith on Oct 3, 2004 — RSS Feed
Dave_smith
Posts: 6
I am living in Trinidad but my server is based in the UK - a time zone about 5 hours different from mine.
When I use SSI to indicate "this page was last updated on ...." I obviously get the time and date of the server on not my local time.
I can't find - despite many Google searches - how to change this time zone. Any advice please?
Thanks.
Dave
Joe Gillespie
Posts: 528
Well, you can't change the timezone of your server so you have to add the five hours on your page. Just pass the server time to this simple JavaScript function and it will add five hours (or whatever).
function makeLocal(serverTime)
{
var hoursOffset = 5;
localTime = new Date();
localTime.setHours(localTime.getHours()+hoursOffset);
return localTime;
}
I trust that you know how to call this from your SSI.
Dave_smith
Posts: 6
You could save me some research by dropping a few hints on how to call this script from my SSI. ![]()
Joe Gillespie
Posts: 528
I'd need to see the SSI to be certain. Are you inserting something like #localtime# and not just #time# or #gmtime# ?
Make a JavaScript section in the head of the page, insert the function and replace #localtime# with javascript:makeLocal(#localtime#)
That's the principle but I have no way to test this myself.
You must login to reply

