Re: Managing time zones

From: Date: Thu, 04 Apr 2002 02:25:45 +0000
Subject: Re: Managing time zones
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91459@lists.php.net to get a copy of this message
Hi One method is to use javascript to get the clients date/time then create a diff between that and your time and use it to change the display times. Here is a demo of getting the remote date and time <pre> <html> <head>
        <title>Untitled</title>
<?if(!isset($Submit)):?>
        <script language="JavaScript">
        <!-- begin
        function gogo() {
        var dt = new Date();
        var mm,dd,yy,h,m,s;
        mm = dt.getMonth()+1;
        dd = dt.getDate();
        yy = dt.getYear();
        h = dt.getHours();
        m = dt.getMinutes();
        s = dt.getSeconds();
        document.location="<?echo $PHP_SELF?>?Time="+h+":"+m+":"+s+"&Submit=yes&Month="+mm+"&Day="+dd+"&Year="+yy 
        }
        // end -->
        </script>
<?endif?> </head> <body<?if(!isset($Submit)):?> onload="gogo()"<?endif?>> <? if(isset($Submit)):
        echo "Remote date = $Month/$Day/$Year $Time <br>";
endif; ?> </body> </html> </pre> Tom At 10:38 AM 4/04/2002, Miguel Cruz wrote:
Among other user preferences, I need to record their time zone, so that timestamps retrieved from a database can be displayed in their local time. There are all sorts of schemes for this, providing varying levels of detail (for a lot of detail, have a look in /usr/share/zoneinfo!). I would probably be willing to sacrifice subtle city-by-city idiosyncracies in exchange for simplicity as long as I were still able to handle daylight savings time for major populated areas. Recording "+0400", for instance, is not good enough. Has anyone worked with this in the context of PHP? Any good pointers or inspiration? Thanks. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#91459) next »