KReporter - Wrong data displayed correctly

I’m running a KReport on the Leads table, my user has the timezone set to America/New_York, when I select Leads where “Date Created” is between 2018-01-10 and 2018-01-11, the returned data is Leads where “Date Created” is between 2018-01-10 and 2018-01-11 UTC time, not America/New_York; however data is displayed with the expected timezone (America/New_York).

I’m using KReport 3.0 on SuiteCRM Version 7.4.1 (Sugar Version 6.5.20)

Rolando,
handling of timezone in select was introduced in KReporter 4.
Doing a Kreporter Update shall solve the problem. Migrating from KReporter 3 requires a bit work.
Before you update, you may try to add following code snippet in file modules/KReports/KReportQuery.php line 148 (line number as in KReporter 3.1, i don’t have 3.0 anymore)

// do time handling treating passed in values as User Timezone converting to UTS
if($whereArrayEntry[‘type’] == ‘datetime’){
$userTimezZone = $GLOBALS[‘current_user’]->getPreference(‘timezone’);
if($whereArrayEntry[‘valuekey’] != ‘’){
$valuefromdate = SugarDateTime::createFromFormat(‘Y-m-d H:i:s’, $whereArrayEntry[‘valuekey’], new DateTimeZone($userTimezZone));
$valuefromdate->setTimezone(new DateTimeZone(‘UTC’));
$this->whereArray[$whereId][‘valuekey’] = $valuefromdate->format(‘Y-m-d H:i:s’);
$this->whereArray[$whereId][‘value’] = $valuefromdate->format(‘Y-m-d H:i:s’);
}
if($whereArrayEntry[‘valuetokey’] != ‘’){
$valuetodate = SugarDateTime::createFromFormat(‘Y-m-d H:i:s’, $whereArrayEntry[‘valuetokey’], new DateTimeZone($userTimezZone));
$valuetodate->setTimezone(new DateTimeZone(‘UTC’));
$this->whereArray[$whereId][‘valuetokey’] = $valuetodate->format(‘Y-m-d H:i:s’);
$this->whereArray[$whereId][‘valueto’] = $valuetodate->format(‘Y-m-d H:i:s’);
}
}

Insert in

Val

1 Like