XF 2.2 Last Activity - incorrect Timezone?

PaulProe

Member
I am seeing the last activity of members is reported incorrectly, it appears it is reporting UTC time instead of the timezone of the user or the forum.

I thought this was due to the user's timezone preference being incorrect but after checking and determining all were correct, I can't find another place that would cause this.

Is this a bug or is there a spot I'm missing? Our location is Saint Louis, MO, USA ((UTC-06:00) Central Time (US & Canada)) Our server is located in Ann Arbor, MI, USA ((UTC-05:00) Eastern Time (US & Canada) but the Last Activity is reporting UTC time (UTC) Dublin, Edinburgh, Lisbon, London)

Any ideas on how to correct this display difference?

Paul
 
Additional Info: I've tried changing the server timezone using the PHP options settings. That doesn't seem to have any effect. Does the database take a timestamp or does it record actual time?

Did some additional searches and I am getting the impression this is not a new issue.
 
Same here. I've set the time zone (correctly) in the control panel to USA Eastern Time Zone.

The time stamps on posts aren't even close to being correct. It's five hours off. My 2:07pm post is showing up as 7:07pm on the timestamp. The time zone in the control panel is set to USA Eastern (-5 UTC), which is where I'm located.

What's up with that? :-)
 
I can change my server's time to whatever I want - and it has absolutely no impact on the timezone display or results in Xenforo. I read somewhere that Xenforo time is hardcoded to UTC (00:00) but I don't understand why the timezone offsets are correcting for it. Unless the coding is incorrect. Is the hardcoding reading a different timeclock than the server? I don't know.

Haven't been able to get anyone from the Xenforo team to comment. Digging around, it seems to be an identified problem with no solution

? ? ?
 
I can change my server's time to whatever I want - and it has absolutely no impact on the timezone display or results in Xenforo. I read somewhere that Xenforo time is hardcoded to UTC (00:00) but I don't understand why the timezone offsets are correcting for it. Unless the coding is incorrect. Is the hardcoding reading a different timeclock than the server? I don't know.

Haven't been able to get anyone from the Xenforo team to comment. Digging around, it seems to be an identified problem with no solution

? ? ?

Yep... no matter what time zone I choose, nothing changes with the stamps on posts.
 
happy for you but my problem persists. Based on your input, I rechecked our settings

Basic Settings: timezone: UTC-6:00 Central US

My personal settings: UTC-6:00 Central US

The server we are hosted on is in Ann Arbor, MI and set to UTC-5:00 Eastern US. I can change the server time using PHP settings but it doesn't seem to make any diffence.

Anyone have any ideas

Paul
 
My personal settings: UTC-6:00 Central US

What, exactly, do you mean by "personal settings."

I discovered that when I'm on my own forum, viewing it as a member, that the time zone in my preferences was set at UTC instead of my own time zone. Shown here corrected.

1646621336071.webp

Is that what you meant?
 
happy for you but my problem persists. Based on your input, I rechecked our settings
Your forum is displaying central time for me (as a guest). Does the problem go away if you log out and/or try a different browser?

I can change the server time using PHP settings but it doesn't seem to make any diffence.
If you're referring to the PHP default timezone, XF sets it to UTC automatically (disregarding any previous setting). Internally, times are stored as Unix timestamps (in UTC, based on your server clock) and then adjusted for display based on the user preference.
 
PatriotGB
My terminology may be confusing - My account preference is set to UTC -06:00 Central US. Similarly, your's is set to UTC -05:00 Eastern

I also checked the guest times setting which is also Central Timezone. That appears to be verified by the post that Jeremy P put up. He is seeing Central time when he visited our site as a guest.

Jeremy, logging out or using a different browser makes no difference.

If you're referring to the PHP default timezone, XF sets it to UTC automatically (disregarding any previous setting). Internally, times are stored as Unix timestamps (in UTC, based on your server clock) and then adjusted for display based on the user preference.
Jeremy, you've just confirmed what I believed, that XF internally sets the time to UTC. The issue I am chasing is how various statistics & metrics don't compensate for the timezone shift but display in UTC. An example is when the last time a user was on the site. Rather than show it as X:XX Central time, it displays as UTC time which is 6 hrs different for us.

If you are aware of the issue, you can mentally compensate. But the typical member/user is confused. We are getting comments, "Mark must have been up all night, he was posting at 3AM when in reality, he was posting at 9PM (Central US timezone vs UTC Time)

I am trying to figure out how to get these corrected so they display the correct times (or compensated times).

This is a screen clip I just took, the current time is 10:20 Central Standard Time. You can see the times the users were on earlier this evening and how they are being reported
Screenshot 2022-03-06 222047.webp
JimW was at 9:03PM our time, WallyB at 8:44PM, etc

Paul
 
The issue I am chasing is how various statistics & metrics don't compensate for the timezone shift but display in UTC.
Oh, I see now. This issue only affects the last activity listing on the member list, not on the profile or user card. This is a bit of a design issue where the results are being cached by a visitor (or user in the UTC timezone).

We'll take a look at it, but in the meantime you can disable caching for the member stat to work around this:
screenshot-iDXUln.webp
 
@Jeremy P , your work-around did just that. Disable the cache and it reports properly. Makes no sense but it works.

Can you explain how the cache would be useful for this type thing and why it would be enabled/disabled

Thanks

Paul
 
Can you explain how the cache would be useful for this type thing and why it would be enabled/disabled
It caches the results for the given period of time so that they don't have to be computed every time the page is viewed. It's useful when it is computationally expensive to fetch the results. In this case, it's probably not especially useful.

Makes no sense but it works.
Because of a design flaw, the cache currently writes the results in the time zone of the user who triggered the computation. So if the cache is stale, a visitor from the UTC timezone will cause the results to be cached in UTC time.
 
Top Bottom