Datetime data reflected in User's preferred time zone after conversion from UTC
Scenario
When running reports that contain date\time information that is stored in the database in UTC format the reports are showing the user's preferred time zone instead of the company's specified time zone.
Resolution
To display the timezone information in the company timezone instead of the user's perferred time zone, you can change the setText method (Example from \Reports\HRMCourseAttendeeStatusList):
From:
void setText()
{
periode.text(strfmt("@SYS53184", date2StrUsr(DateTimeUtil::date(hrmCourseTable.StartDateTime), DateFlags::FormatAll),
date2StrUsr(DateTimeUtil::date(hrmCourseTable.EndDateTime), DateFlags::FormatAll)));
}
To:
...
periode.text(strfmt("@SYS53184", date2StrUsr(DateTimeUtil::date (DateTimeUtil::applyTimeZoneOffset(hrmCourseTable.StartDateTime, DateTimeUtil::getUserPreferredTimeZone())), DateFlags::FormatAll),
date2StrUsr(DateTimeUtil::date (DateTimeUtil::applyTimeZoneOffset(hrmCourseTable.endDateTime, DateTimeUtil::getUserPreferredTimeZone())), DateFlags::FormatAll)));
...
}
Comments
- Anonymous
August 09, 2010
Not sure I understand this correctly but shouldn't it say DateTimeUtil::getCompanyTimeZone() instead of DateTimeUtil:getUserPreferredTimeZone() if you want the company timezone?