From 7956dc4addf6cd5047abc36e9b70b9673283a8cc Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 8 Jul 2017 21:42:49 -0300 Subject: [PATCH] Fix Mysql Timezone --- objects/include_config.php | 9 +++++++++ objects/video_statistic.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/objects/include_config.php b/objects/include_config.php index d3723de923d2..a5e0ab25dd9c 100644 --- a/objects/include_config.php +++ b/objects/include_config.php @@ -6,6 +6,15 @@ $global['mysqli'] = new mysqli($mysqlHost, $mysqlUser,$mysqlPass,$mysqlDatabase); +$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); +$global['mysqli']->query("SET time_zone='$offset';"); + require_once $global['systemRootPath'] . 'objects/configuration.php'; $config = new Configuration(); diff --git a/objects/video_statistic.php b/objects/video_statistic.php index 656eac81027e..22874934fec3 100644 --- a/objects/video_statistic.php +++ b/objects/video_statistic.php @@ -88,7 +88,7 @@ static function getTotalToday($video_id, $hour=0, $returnArray = array()) { if ($hour >= 24) { return $returnArray; } - $date = date("Y-m-d h:i:s {$hour}", time()); + $date = date("Y-m-d {$hour}", time()); //echo $date;exit; $returnArray[] = static::getStatisticTotalViews($video_id, false, $date.":00:00", $date.":59:59"); $hour++;