Timezone Issue

Please describe the issue you're having
If you accept the answer, please mark the topic as [SOLVED] by clicking the tick.

Moderators: RussH, cptr13

Forum rules
Just please remember to play nicely once you walk through the door. You can disagree with us, or any other commenters in this forum, but respect our space and keep your comments directed to the topic at hand.
Post Reply
dcdefiore_reiss
Posts: 2
Joined: 12 Mar 2019, 13:12
what is two(2) plus three(3) ?: 5

Timezone Issue

Post by dcdefiore_reiss » 12 Mar 2019, 13:24

Good Morning,

I've installed and am customizing and configuring OpenCATS. Love it so far.

I've run into a problem with timezones though that I'm trying to figure out.

It's currently 8AM EST where I am. I'm running OpenCATS on an Ubuntu Server.

helpdesk@cen-s-web01:~$ date
Tue Mar 12 08:00:00 EDT 2019

PHP has the date correct as well:
Tuesday 12th of March 2019 08:00:00 AM

Now, if I have CATS set to an Offset of -5, emails that utilized %DATETIME% show the correct time, but the activity log inside of CATS shows a time of 4 hours in the future. So my 08:00:00AM activity shows up as 12:00:00 PM. If I change the offset in CATS to -9, the activity log shows the correct time, but the %DATETIME% variable that goes out in an email is messed up.

Any ideas?

dcdefiore_reiss
Posts: 2
Joined: 12 Mar 2019, 13:12
what is two(2) plus three(3) ?: 5

Re: Timezone Issue

Post by dcdefiore_reiss » 13 Mar 2019, 12:55

So I suppose the function getAdjustedDate from DateUtility uses the system time, but my system time is correct. So I changed the function by removing the addition of the TimeZoneOffset

From lib\DateUtility.php

Code: Select all

public static function getAdjustedDate($format = 'U', $date = false)
    {
        if ($date === false)
        {
            $date = time();
        }

        $unixTime = mktime(
            date('H', $date), //+ $_SESSION['CATS']->getTimeZoneOffset(),
            date('i', $date),
            date('s', $date),
            date('m', $date),
            date('d', $date),
            date('Y', $date)
        );

        return date($format, $unixTime);
    }

Post Reply