The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

You would then alter the onclick handler to pass userTimeZoneOffset in place of timeToAttach.

Yet another method would be to set a cookie using javascript, then read the cookie on the server with PHP.
<script>
now = new Date();
cookievar = now.getTime();
//or
//cookievar = now.getTimezoneOffset();
myCookie = "thevar="+cookievar; //read on server using cookie name "thevar"
document.cookie = myCookie + ';';
</script>

yeah it must be. it must be the time that the system time is set to.
where else could it get the time from?
i was just trying to work out how reliable it is.
pretty reliable i'd say as most people have close-enough the right time on their computer
very few people would have their time set completely wrong i'd guess.

that's great - worked a treat
haven't done the getting it from within php yet but i can see it's working from the address bar
went for the offset version (in the url, not cookie) - seemed the simplest/shortest

is there a way to add the info to the end of each url on the page, from within that piece of code in the <head> rather than attaching individually to each url?

because i'm only going to do this time test on the first page that the user arrives at on the site (and obviously they could arrive at any page what-so-ever).

so is there any way to say from within the javascript in the head :
"add
'onclick="location=this.href+'?time='+timeToAttach; return false;">'
to all the same-site urls on this page" ?

works with both text and img links - haven't got round to the php bit yet but this javascript certainly seems to work on my setup (mac ie5.15)

as i mentioned i'm pretty clueless with javascript.
is the above script - some of this part.. :
if ( href.indexOf('http://www.whatever.com/') == 0 ) {
if ( href.indexOf('?') == -1 ) {
href += '?offset=' + offset;
} else {
href += ';offset=' + offset;
..trying to check to see if the offset has already been set by a previsous page? or am i misreading that? (i'm probably misreading it)
i don't actually want to do that - check to see if the offset has been set by a previous page as it'd be better to do that server side - as that's what is going to be sending the javascript in the first place

Just be sure that even if the script does not append the time to the links in Netscape 4 or 6, the links at least DO work regularly (without the time being passed).

This method's getting a little messy. In my opinion, the best method would be to set a cookie with the user's time offset. You'd only have to set the cookie once. Then, on the server, you can read the offset easily and using GMT get the client time.

Yes, I concur with the cookie plan - setting the time for all the links at the time the page is loaded is a bit useless, since they could take 1 minute or 1 hour to read the page, but the time reported would be the same, so that doesn't tell you a lot!

That's why setting the time at the instant of link clicking was better, but catching the timeZoneOffset just the once and using that is by far the best.

the user time is needed for one particular page on my site - if that page is the first one they go to i'm going to try and get the page to do a reload in order to get their time - and a reload wouldn't help if i was using the url method

yeah, 1380 does mean something (i thought it was gibberish)-
1380 divided by 60 equals 23
with IE i got -60 which is right
23 is a day minus an hour, or minus 60

so all i have to do is treat different browser's respnses differently serverside - which i don't think'll be a major prob. what i need to know is how different broser/platfoms cope with the javascript now.getTimezoneOffset()

FAVOUR REQUEST :

could anyone let me know how the cookie offset time compares with gmt time? please?

go here
then reload the page so you'll see an offset number
and let me know what the offset is and how it compares with the gmt time which is also on that page
also if you could let me know what platform/browser/browser version you're using.

I don't know what you did but be careful....make sure you are treating NS4 for mac and PC differently. Because on my platform, IE, NS4, NS6, and Moz all give the same offset. The difference is between mac's and pc's.

Correct (I'm in the UK), but you might want to make sure a zero is displayed instead of a blank!

Edit:

NOT correct.... having done my own test, have realised that -60 should be returned because of BST. Came back here and noticed that johnyboy said this earlier. Perhaps my cookie was not sent (I'm running IE6)...