? sites/default/files
? sites/default/settings.php
Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v
retrieving revision 1.329
diff -u -p -r1.329 CHANGELOG.txt
--- CHANGELOG.txt	19 Aug 2009 22:46:05 -0000	1.329
+++ CHANGELOG.txt	20 Aug 2009 16:43:30 -0000
@@ -76,6 +76,8 @@ Drupal 7.0, xxxx-xx-xx (development vers
     * If your site is being upgraded from Drupal 6 and you do not have the
       contributed date or event modules installed, user time zone settings will
       fallback to the system time zone and will have to be reconfigured by each user.
+    * User-configured time zones now serve as the default time zone for PHP
+      date/time functions.
 - Filter system:
     * Refactored the HTML corrector to take advantage of PHP 5 features.
 - Removed ping module:
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.298
diff -u -p -r1.298 bootstrap.inc
--- includes/bootstrap.inc	20 Aug 2009 07:24:40 -0000	1.298
+++ includes/bootstrap.inc	20 Aug 2009 16:43:30 -0000
@@ -1498,6 +1498,7 @@ function _drupal_bootstrap($phase) {
     case DRUPAL_BOOTSTRAP_VARIABLES:
       // Load variables from the database, but do not overwrite variables set in settings.php.
       $conf = variable_initialize(isset($conf) ? $conf : array());
+      date_default_timezone_set(drupal_get_user_timezone());
       break;
 
     case DRUPAL_BOOTSTRAP_SESSION:
@@ -1540,6 +1541,21 @@ function _drupal_bootstrap($phase) {
 }
 
 /**
+ * Return the time zone of the current user.
+ */
+function drupal_get_user_timezone() {
+  global $user;
+  if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
+    return $user->timezone;
+  }
+  else {
+    // Ignore PHP strict notice if time zone has not yet been set in the php.ini
+    // configuration.
+    return variable_get('date_default_timezone', @date_default_timezone_get());
+  }
+}
+
+/**
  * Validate the HMAC and timestamp of a user agent header from simpletest.
  */
 function drupal_valid_test_ua($user_agent) {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.964
diff -u -p -r1.964 common.inc
--- includes/common.inc	19 Aug 2009 20:19:36 -0000	1.964
+++ includes/common.inc	20 Aug 2009 16:43:30 -0000
@@ -1944,13 +1944,7 @@ function format_interval($timestamp, $gr
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
   $timezones = &drupal_static(__FUNCTION__, array());
   if (!isset($timezone)) {
-    global $user;
-    if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
-      $timezone = $user->timezone;
-    }
-    else {
-      $timezone = variable_get('date_default_timezone', 'UTC');
-    }
+    $timezone = date_default_timezone_get();
   }
   // Store DateTimeZone objects in an array rather than repeatedly
   // contructing identical objects over the life of a request.
Index: includes/session.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/session.inc,v
retrieving revision 1.70
diff -u -p -r1.70 session.inc
--- includes/session.inc	1 Jul 2009 12:47:30 -0000	1.70
+++ includes/session.inc	20 Aug 2009 16:43:30 -0000
@@ -269,6 +269,7 @@ function drupal_session_regenerate() {
       ->condition('sid', $old_session_id)
       ->execute();
   }
+  date_default_timezone_set(drupal_get_user_timezone());
 }
 
 /**
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.139
diff -u -p -r1.139 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	20 Aug 2009 03:16:06 -0000	1.139
+++ modules/simpletest/drupal_web_test_case.php	20 Aug 2009 16:43:30 -0000
@@ -1105,6 +1105,7 @@ class DrupalWebTestCase extends DrupalTe
     variable_set('install_task', 'done');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', 'simpletest@example.com');
+    variable_set('date_default_timezone', date_default_timezone_get());
     // Set up English language.
     unset($GLOBALS['conf']['language_default']);
     $language = language_default();
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.64
diff -u -p -r1.64 common.test
--- modules/simpletest/tests/common.test	17 Aug 2009 19:14:41 -0000	1.64
+++ modules/simpletest/tests/common.test	20 Aug 2009 16:43:30 -0000
@@ -1240,6 +1240,8 @@ class FormatDateUnitTest extends DrupalW
     $user = user_load($test_user->uid, TRUE);
     $real_language = $language->language;
     $language->language = $user->language;
+    // Simulate a Drupal bootstrap with the logged-in user.
+    date_default_timezone_set(drupal_get_user_timezone());
 
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test a different language.'));
     $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.'));
@@ -1252,6 +1254,8 @@ class FormatDateUnitTest extends DrupalW
     // Restore the original user and language, and enable session saving.
     $user = $real_user;
     $language->language = $real_language;
+    // Restore default time zone.
+    date_default_timezone_set(drupal_get_user_timezone());
     drupal_save_session(TRUE);
   }
 }
