note 76397 deleted from function.date by felipe
| From: | felipe@php.net | Date: | Sat, 05 Jan 2008 01:57:37 +0000 |
| Subject: | note 76397 deleted from function.date by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134802@lists.php.net to get a copy of this message | ||
Note Submitter: Eren - erenezgu at gmail.com
----
here is a simple code to print the time according to the clients timezone offset. This code gets the
clients timezone with javascript and redirects the page to itself with timezone offset as a
parameter.
clienttime.php :
<?php
if ( isset($_GET['clientGMT']) ){
$clientGMT=intval( $_GET['clientGMT'] );
$serverGMT=intval( date('Z') );
echo date('H:i:s',time()+$clientGMT-$serverGMT);
}
else {
?>
<SCRIPT TYPE="text/javascript">
<!--
var clientGMT=( (new Date()).getTimezoneOffset()*60)*(-1) ;//client timezone offset in seconds
document.location='clienttime.php?clientGMT='+clientGMT ;
//->
</SCRIPT>
<?php
}
?>