Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ticket time is showing wrong #3654

Closed
lijothelegend opened this issue Feb 4, 2017 · 30 comments
Closed

ticket time is showing wrong #3654

lijothelegend opened this issue Feb 4, 2017 · 30 comments

Comments

@lijothelegend
Copy link

Ticket time is showing wrong . I have checked in my server time and my sql server time is correct there.

os info
os ticket my sql time
os ticket
os timezone
osdate

Ticket time is showing wrong . I have checked in my server time and my sql server time is correct there.

@iHunt101
Copy link

iHunt101 commented Feb 6, 2017

Try to check your php.ini conf and set your time zone..

@lijothelegend
Copy link
Author

lijothelegend commented Feb 6, 2017 via email

@fdellwing
Copy link

If the time is wrong as you state, what should the time be? By how much is it off?

@lijothelegend
Copy link
Author

lijothelegend commented Feb 6, 2017 via email

@fdellwing
Copy link

Well, this is already know: #3583

@fdellwing
Copy link

fdellwing commented Feb 6, 2017

Looked into it and are completely confused...

So in the ost_config is correct 'Asia/Kolkata' (+5:30), in class.format.php function datetime $cfg->getTimezone() is 'Asia/Kolkata' (+5:30) but 2 seconds later after passing it to IntlDateFormatter we are in 'Asia/Jerusalem' (+4:30). How??

Edit: Found it. It's an error in the IntlDateFormatter.

<?php
$formatter = new IntlDateFormatter('de',3,3,'Asia/Kolkata',IntlDateFormatter::GREGORIAN,null);
    echo $formatter->format(time());
?>

This should be 'now + 5:30' but is 'now + 4:30'!

@FossPrime
Copy link
Contributor

@fdellwing We've ran into this issue on multiple occasions do you have any more details to put in a fix?

@fdellwing
Copy link

Not yet, have to take a closer look at the IntlDateFormatter, if there are any workarounds.

@FossPrime
Copy link
Contributor

From #3583

dbinoj commented on Dec 31, 2016
The timezone returned by timezone_name_from_abbr can not be trusted as it just selects the first result sorting the tz name alphabetically. This messes up times displayed in the site even though timezone in OSTicket System Settings, OSTicket User Prefs, php.ini, MySQL, Server OS are all set to the same value.

Eg. IST refers to Israel/Indian/Irish Standard Times (Ref: List_of_time_zone_abbreviations)
One may intend to use Indian/Irish timezone but "Asia/Jerusalem" comes first alphabetically.
Few other TZs which I found to have duplicates are ACT, AMT, BST, etc.,

Either function get_from_database in class.timezone.php:165 should be modified to translate ambiguous timezones with some other reference value or a better method must be implemented.

Related StackOverflow answer: http://stackoverflow.com/a/30958892

It seems like the interpretation can change for strange reasons. CST db_timezone was being interpreted as UTC in a test install... I restarted the server twice and had the same issue. To debug it I started installing php-devel, php-xdebug and restarting the webserver... but then the problem disappeared and CST correctly resolved to America/Chicago. 0_0

@fdellwing
Copy link

CST will never be interpreted as UTC by timezone_name_from_abbr. You must have run in another problem. Did you manually queried your DB for @@system_time_zone? The old version (without my PR) just queries the DB for this.

@deependhulla
Copy link

deependhulla commented Feb 27, 2017

To remove timezone issue with osticket DB timezone as : IST (Interpreted as Asia/Jerusalem)
http://osticket.com/forum/discussion/89257/v1-10-timezone-misinterpreted
#3654
#3583

we have done quick fix ain include/class.config.php

Search for line having
function getDbTimezone()

in this function you would last line as
return $this->get('db_timezone');
Comment this line , and add below two line
$dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone;

The function would like below.
function getDbTimezone() { if (!$this->exists('db_timezone')) { require_once INCLUDE_DIR . 'class.timezone.php'; $this->persist('db_timezone', DbTimezone::determine()); } $dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone; // return $this->get('db_timezone'); }

This will help a lot till proper code fix is there.

@lijothelegend
Copy link
Author

Thanks all,
It has been fixed

@fdellwing
Copy link

@deependhulla I hope you don't want to promote that as a valid solution. If you want a proper solution, take a look at my PR #3663

@deependhulla
Copy link

deependhulla commented Feb 28, 2017

@fdellwing my suggestion is for quick fix, so that work get started specially who are looking forward to implement osticket and have got all correct but basic timezone feature is creating problem to start off , this would help them using and exploring octicket's features and power.

Actually would prefer original core osticket fix this timezone issue asap.
and/or give option for also selecting time-zone for database too.

overall I love osticket.
thanks to octicket team too for such a wonderful product.

@elambro
Copy link

elambro commented Apr 12, 2017

For Googlers, if your database time is set to GMT, OSTicket reads this as 'Europe/London' instead of UTC. Your times will then be 1 hour off during DST. To fix this, change includes/class.config.php. Change the method OsticketConfig::getDbTimezone to this:

function getDbTimezone() {
        if (!$this->exists('db_timezone')) {
            require_once INCLUDE_DIR . 'class.timezone.php';
            $this->persist('db_timezone', DbTimezone::determine());
        }
        $db = $this->get('db_timezone');
        if ( $db === 'Europe/London') {
            $db = 'UTC';
        }
        return $db;
    }

@thiru506
Copy link

@deependhulla ...Thank you very much....your given a proper solution..!!!

@mxyq
Copy link

mxyq commented Apr 19, 2019

耐你们

@antiuser
Copy link
Contributor

antiuser commented May 9, 2019

Yes, this patch good, but this is hardcoded function. Im using Asia/Yekaterinburg (GMT +5.00) but in osticket i see in tickets date as GMT +4.00.
@deependhulla thank you

@kanthans
Copy link

To remove timezone issue with osticket DB timezone as : IST (Interpreted as Asia/Jerusalem)
http://osticket.com/forum/discussion/89257/v1-10-timezone-misinterpreted
#3654
#3583

we have done quick fix ain include/class.config.php

Search for line having
function getDbTimezone()

in this function you would last line as
return $this->get('db_timezone');
Comment this line , and add below two line
$dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone;

The function would like below.
function getDbTimezone() { if (!$this->exists('db_timezone')) { require_once INCLUDE_DIR . 'class.timezone.php'; $this->persist('db_timezone', DbTimezone::determine()); } $dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone; // return $this->get('db_timezone'); }

This will help a lot till proper code fix is there.

Hi
We were facing the same issue and had applied the above patch in 1.10.5. This has been working well.

However we recently upgraded to 1.12.2 and all our ticket times were weird again, this time it was advancing by 2 hours 30 mins (as if the timezone is +8 instead of +5.30). We just applied the same patch and seems to be working well.

Is the bug still getting carried from 1.10. to 1.12?

@deependhulla
Copy link

To remove timezone issue with osticket DB timezone as : IST (Interpreted as Asia/Jerusalem)
http://osticket.com/forum/discussion/89257/v1-10-timezone-misinterpreted
#3654
#3583
we have done quick fix ain include/class.config.php
Search for line having
function getDbTimezone()
in this function you would last line as
return $this->get('db_timezone');
Comment this line , and add below two line
$dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone;
The function would like below.
function getDbTimezone() { if (!$this->exists('db_timezone')) { require_once INCLUDE_DIR . 'class.timezone.php'; $this->persist('db_timezone', DbTimezone::determine()); } $dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone; // return $this->get('db_timezone'); }
This will help a lot till proper code fix is there.

Hi
We were facing the same issue and had applied the above patch in 1.10.5. This has been working well.

However we recently upgraded to 1.12.2 and all our ticket times were weird again, this time it was advancing by 2 hours 30 mins (as if the timezone is +8 instead of +5.30). We just applied the same patch and seems to be working well.

Is the bug still getting carried from 1.10. to 1.12?

not aware of 1.12 .. but this fix worked for us on osTicket (v1.14.2) again.

@perezalvarezhi
Copy link

I tried both solutions and I might be wrong but I think none worked for me. Also I just updated to 1.14.2 but I dont think there was a fix for this on this version.

Before this fix I saw MST (Interpreted as America/Denver) with 1 hour less than my time.

After doing the solution user @deependhulla proposed above I at least can see my real timezone selected in the Timezone section which is America / Mexico_City but now my time is off by 2 hrs.

Even if I try other time zones more advanced in time for example "America/New_York" which is 2 hours ahead and could compensate my 2 hrs it ends up 4 hrs before not ahead.

Also I checked my server time and it is in MST with the correct time. I checked this by doing the command "date" on the terminal.

Anyone still having this problem? I understend the problem is closed but I cant fix it.

@JediKev
Copy link
Contributor

JediKev commented Jul 13, 2020

@perezalvarezhi

What is your System Timezone set to (Admin Panel > Settings > System > Date and Time Options > Default Timezone)? Is it America / Mexico_City?

Also, what is your Profile Timezone set to (Profile > Preferences > Localization > Timezone)?

Cheers.

@perezalvarezhi
Copy link

@perezalvarezhi

What is your System Timezone set to (Admin Panel > Settings > System > Date and Time Options > Default Timezone)? Is it America / Mexico_City?

Also, what is your Profile Timezone set to (Profile > Preferences > Localization > Timezone)?

Cheers.

Hey there @JediKev I think while reading your questions you helped me figure it out.
I had to enter the default time zone as the same as my server which is in Pacific (Before I stated it is on MST but it is not, it is on Pacific) and then my agent profile in the time zone it is located.

I selected in Admin Panel > Settings > System > Date and Time Options > Default Timezone "America/Los_Angeles" and then in my profiles I had America/Mexico_City.

This way it worked fine.

Thanks!

@JediKev
Copy link
Contributor

JediKev commented Jul 13, 2020

@perezalvarezhi

Awesome! I'm glad you got this resolved!

Cheers.

@feiticeir0
Copy link

feiticeir0 commented Aug 20, 2020

Hi all !
I know this is 2020, but this issue still remains... Had to edit the file class.config.php and return my timezone for this to work... Thank you
EDIT: Sorry, Latest threads are already 2020 . I'm using the latest version 1.14.3

@antiuser
Copy link
Contributor

@JediKev another one with this bug

@JediKev
Copy link
Contributor

JediKev commented Aug 20, 2020

@antiuser

Cool.. you never responded to my message in your issue thread. #5522

Cheers.

@antiuser
Copy link
Contributor

@JediKev this bug found on 1.12.2 version, and i told about this in issue information (up to 1.12.6), this issue comes from old time, and no reaction. Im assume that ticket should be reopened

@Stufo76
Copy link

Stufo76 commented May 6, 2022

To remove timezone issue with osticket DB timezone as : IST (Interpreted as Asia/Jerusalem)
http://osticket.com/forum/discussion/89257/v1-10-timezone-misinterpreted
#3654
#3583
we have done quick fix ain include/class.config.php
Search for line having
function getDbTimezone()
in this function you would last line as
return $this->get('db_timezone');
Comment this line , and add below two line
$dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone;
The function would like below.
function getDbTimezone() { if (!$this->exists('db_timezone')) { require_once INCLUDE_DIR . 'class.timezone.php'; $this->persist('db_timezone', DbTimezone::determine()); } $dvd_db_timezone='Asia/Kolkata'; return $dvd_db_timezone; // return $this->get('db_timezone'); }
This will help a lot till proper code fix is there.

Hi We were facing the same issue and had applied the above patch in 1.10.5. This has been working well.

However we recently upgraded to 1.12.2 and all our ticket times were weird again, this time it was advancing by 2 hours 30 mins (as if the timezone is +8 instead of +5.30). We just applied the same patch and seems to be working well.

Is the bug still getting carried from 1.10. to 1.12?

found again v1.15.7 (26ab7e9) and quick fixed as above, but i think it should be permanently fixed

@mixneko
Copy link

mixneko commented Sep 23, 2022

Dear All
Asia/Taipei also can't be right timezone
it will show "America/Chicago"
for now I follow this code
we have done quick fix ain include/class.config.php Search for line having function getDbTimezone() in this function you would last line as return $this->get('db_timezone'); Comment this line , and add below two line $dvd_db_timezone='Asia/Taipei'; return $dvd_db_timezone; The function would like below. function getDbTimezone() { if (!$this->exists('db_timezone')) { require_once INCLUDE_DIR . 'class.timezone.php'; $this->persist('db_timezone', DbTimezone::determine()); } $dvd_db_timezone='Asia/Taipei'; return $dvd_db_timezone; // return $this->get('db_timezone'); }
please help to fix it
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests