Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 0427785aa49287630d7f1689664584195047536f 1 parent 9b72fca
@daniel-kristjansson daniel-kristjansson authored
Showing with 6 additions and 0 deletions.
  1. +2 −0  classes/Database.php
  2. +4 −0 mythweb.pl
View
2  classes/Database.php
@@ -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
4 mythweb.pl
@@ -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')));
Please sign in to comment.
Something went wrong with that request. Please try again.