Re: Timezone help needed

From: Date: Fri, 25 Aug 2000 18:51:39 +0000
Subject: Re: Timezone help needed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13699@lists.php.net to get a copy of this message
> I've been able to get the offset from the client machine with Javascript > using: > > echo "<SCRIPT LANGUAGE=\"JavaScript\">\n"; > echo "var today = new Date()\n"; > echo "document.writeln(today.getTimezoneOffset()/60)\n"; > echo "</SCRIPT> : \n"; > But I need to get the value of this into a var I can use in php. Try (untested): // discontinue PHP ?> <SCRIPT LANGUAGE="JavaScript"> var today = new Date(); var offset = today.getTimezoneOffset() / 60; document.writeln( "<input type=\"hidden\" name=\"timeOffset\" value=\"" + offset + "\">" ); </SCRIPT> <? // continue PHP This needs to be inside the <FORM> you already have (I assume you have a POST-FORM somewhere in your page). If you have "register_globals" on, you can get $timeOffset in your PHP script when they submit it. If not, you can get $HTTP_POST_VARS[timeOffset] in your PHP script. Dean.

« previous php.general (#13699) next »