Permalink
Browse files

Set php/pl connection timezone to +0:00

The PHP and Perl code uses unix UTC timestamps for internal timekeeping
and use mysql timezone conversions to convert UTC time to DB local time.
Since we keep the DB in UTC now this was doing an unwanted conversion.
Luckily turning this off is just a matter of setting a connection
time_zone value.
  • Loading branch information...
daniel-kristjansson committed Jun 5, 2012
1 parent 9b72fca commit 0427785aa49287630d7f1689664584195047536f
Showing with 6 additions and 0 deletions.
  1. +2 −0 classes/Database.php
  2. +4 −0 mythweb.pl
View
@@ -122,6 +122,8 @@ static function &connect($db_name, $login, $password, $server='localhost', $port
}
// Set database connection to utf8
$dbh->query('SET NAMES utf8;');
+ // Make sure UNIX_TIMESTAMP AND FROM_UNIXTIME do the right things
+ $dbh->query('SET time_zone="+0:00";');
// Return
return $dbh;
}
View
@@ -52,6 +52,10 @@
"Cannot connect to database: $!\n\n";
exit;
}
+# Set database connection to utf8
+ $dbh->prepare("SET NAMES utf8;")->execute();
+# Make sure UNIX_TIMESTAMP AND FROM_UNIXTIME do the right things
+ $dbh->prepare("SET time_zone='+0:00';")->execute();
# Find the path to the modules directory
our $modules_dir = dirname(dirname(find_in_path('modules/tv/init.php')));

0 comments on commit 0427785

Please sign in to comment.