note 56398 deleted from function.date-default-timezone-set by nlopess

From: Date: Thu, 01 Sep 2005 12:05:22 +0000
Subject: note 56398 deleted from function.date-default-timezone-set by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94593@lists.php.net to get a copy of this message
Note Submitter: Eric Z (ezsomething at hotmail) Reason: bad code ---- As an addendum to my prior posting (should appear below), here's how you set BOTH php date functions AND mysql so that they print it in client-local time. Yay PHP+opensource. To make it easier on myself, I put this right in with the opening of the mysql resource. <?php //be sure to start the session before to get this data session_start(); //this isn't the most graceful approach, but if it's set, set the tz if (isset($_SESSION[PROFILE_TZOFFSET])) putenv('TZ='.$_SESSION[PROFILE_TZOFFSET]); //format the timezone for SQL - versions > 4.1.3 - looks like '-07:00' // see http://dev.mysql.com/tech-resources/articles/4.1/time.html?rated=0 $timeZone = preg_replace('/([+-]\d{2})(\d{2})/', '\'\1:\2\'', date('O')); $queryStr = 'SET time_zone='.$timeZone; $execResult = mysql_query($queryStr); //you can check the different times with 'SELECT NOW();' ?>

« previous php.notes (#94593) next »