views:

80

answers:

1
+2  Q: 

UTC within Site

Hi,

I am working on a website that will only be available via the intranet but is a website that is Australia wide ONLY.

The thing is, I have been asked to look into making the site UTC and was wondering how I could go about displaying a clock or determing which timezone the site in running in and so perhaps display a clock on the home page indicating the time in the state of Australia a user is using the site.

Would like some universal type jQuery, Javascript routine that will work out the correct clock time of where the user is located within Australia.

I was looking at http://randomibis.com/coolclock/ but from the looks of it, I need to specify the correct GMTOffset.

Could this value be determined somehow or is this something the user will need to specify?

Thanks.

+2  A: 

The GMT offset of a given client is available within the browser via the Date class:

var today = new Date();  
var offset = -(today.getTimezoneOffset()/60);

Via http://www.24hourapps.com/2009/03/javascript-gmtutc-timezone-offset.html

jakemcgraw
Thanks for that - ould I then use this and pass into coolClocks.js?
tonsils
Unsure why there is a - against the offset because if I am in Australia, that is placing me -10 instead of +10?
tonsils
Depends on what you're trying to accomplish, you can remove the minus sign if you like.
jakemcgraw