In PHP:
<?php define('TIMEZONE', 'Europe/Paris'); date_default_timezone_set(TIMEZONE);
Für MySQL:
<?php $now = new DateTime(); $mins = $now->getOffset() / 60; $sgn = ($mins < 0 ? -1 : 1); $mins = abs($mins); $hrs = floor($mins / 60); $mins -= $hrs * 60; $offset = sprintf('%+d:%02d', $hrs*$sgn, $mins); //Your DB Connection - sample $db = new PDO('mysql:host=localhost;dbname=test', 'dbuser', 'dbpassword'); $db->exec("SET time_zone='$offset';");
Jetzt teilen PHP und MySQL innerhalb Ihrer App dieselbe Zeitzone, ohne dass Sie php.ini oder die MySQL-Konsole ändern müssen.
Dies stammt aus einem Artikel auf SitePoint.