From 8faf4d6f471452d293bad0f5ff5aa2cd85e7bfd5 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 30 Jun 2016 10:16:34 -0500 Subject: [PATCH] Fix get_time_spent_on_the_platform - refs BT#11032 --- main/inc/lib/tracking.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index c041d5858f..4b7df5f56d 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -1358,16 +1358,18 @@ class Tracking $timeFilter = 'last_week'; } - $today = date('Y-m-d H:i:s'); + $today = new DateTime('now', new DateTimeZone('UTC')); switch ($timeFilter) { case 'last_7_days': - $new_date = date('Y-m-d H:i:s', strtotime('-7 day')); - $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") '; + $newDate = new DateTime('-7 day', new DateTimeZone('UTC')); + $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'"; + $condition_time .= " AND logout_date <= '{$today->format('Y-m-d H:i:s')}') "; break; case 'last_30_days': $new_date = date('Y-m-d H:i:s', strtotime('-30 day')); - $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") '; + $condition_time = " AND (login_date >= '{$new_date->format('Y-m-d H:i:s')}'"; + $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') "; break; case 'custom': if (!empty($start_date) && !empty($end_date)) {