Skip to content

Commit

Permalink
Fix Mysql Timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Jul 9, 2017
1 parent 084e373 commit 7956dc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions objects/include_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion objects/video_statistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 7956dc4

Please sign in to comment.