note 56398 added to function.date-default-timezone-set

From: Date: Thu, 01 Sep 2005 11:41:07 +0000
Subject: note 56398 added to function.date-default-timezone-set
Groups: php.notes 
Request: Send a blank email to php-notes+get-94592@lists.php.net to get a copy of this message
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();' ?> ---- Manual Page -- http://www.php.net/manual/en/function.date-default-timezone-set.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56398 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56398&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56398&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94592) next »