Jump to content


Timezone Set But Activity Shows UTC Time

swarm activity time

  • Please log in to reply
18 replies to this topic

#1 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 24 February 2014 - 06:27 PM

Hi, I have setup a Swarm evaluation using the OVA (2014.1) on a network server. Everything is working great, except on the HOME page where it lists the Activity. I have set the timezone to US/Central, but the times are incorrect (showing as UTC time). If I go to the HISTORY page, they appear correctly (US/Central time).

Obviously not a huge issue, but I am wondering if I'm missing something in the configuration or maybe this is the expected behavior. Any ideas?

Thanks!

#2 P4dmountney

P4dmountney

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts
  • LocationVictoria BC

Posted 24 February 2014 - 07:16 PM

Does the activity time show incorrectly for new activity, after swarm started receiving activity from your triggers?

#3 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 24 February 2014 - 07:35 PM

Yes, that's correct. There are a bunch of activity entries from "About a year ago" that were there when I first launched it. Now, any new activity that is displayed on the Home page is showing the UTC time.

#4 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 24 February 2014 - 08:12 PM

View Postmmills, on 24 February 2014 - 06:27 PM, said:

Hi, I have setup a Swarm evaluation using the OVA (2014.1) on a network server. Everything is working great, except on the HOME page where it lists the Activity. I have set the timezone to US/Central, but the times are incorrect (showing as UTC time). If I go to the HISTORY page, they appear correctly (US/Central time).

That actually seems like a fair bit of an issue; kind of you to say it isn't though :)

Its _acting_ like php is running in the GMT timezone; perhaps your efforts to set the timezone on the Swarm system are being over-ridden by a php.ini setting or otherwise didn't take.

Would you be so kind as to post the 'date' section from your phpinfo page (including the data.timezone value) you can access php info by logging into Swarm as an admin or super user and visiting:
http://<swarm-host>/info/phpinfo

That will help us be 100% certain if PHP thinks its operating GMT or US/Central which will assist greatly in narrowing down the issue.

Thanks for your assistance and sorry for the trouble.

#5 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 24 February 2014 - 09:45 PM

Looks like that is the issue. I initially updated the time zone from the web interface to manage the VM (http://<swarm>:5480).

Here's the PHP info:

date/time support enabled
"Olson" Timezone Database Version 2013.3
Timezone Database internal
Default timezone UTC

Directive Local Value Master Value
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenith 90.583333 90.583333
date.sunset_zenith 90.583333 90.583333
date.timezone no value no value

#6 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 24 February 2014 - 09:58 PM

First off its important to note that once you fix this issue, old entries will likely continue to have the incorrect time but new entries should be correct going forward.

Out of curiosity, are you running against a windows p4d?
I ask as we parse the timezone from the p4 info result when possible but the windows p4d output isn't currently parseable for us.
When we cannot parse the p4 info timezone we fallback to the php or system timezone (which is what appears to be happening for you).


Regardless, if you set the timezone through the web ui its possible you need to restart apache (or the whole vm if that's easier for you) for the change to fully take effect. If you are not confident that's happened already I would advise trying that first and submitting a change to see if it sorts you out.

If apache has been restarted and the issue persists; If you are able to shell into the box and edit your php.ini (location is likely /etc/php/php.ini) you can locate the line for:
date.timezone

Uncomment it and set the value to:
date.timezone = "America/Chicago"

Or any other value you feel appropriate from:
http://ca.php.net/ma...n/timezones.php

You'll then need to restart apache for the adjustment to take effect and submit a change to see if it fixed it.


Kindly advise if either of those approaches gets you sorted.
If it does we'll dig in a bit more on our end to see how we can improve the experience as it certainly doesn't sound ideal at the moment :)

#7 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 25 February 2014 - 05:10 PM

Thanks Geoff. You are correct, Swarm is connecting to a Windows based Perforce server.

After updating the php config file with the timezone and restarting, new activities are showing the correct time. However, on the History page, the times are now off by 6 hours.

#8 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 25 February 2014 - 05:25 PM

Well... technically I still feel like I solved your problem you never explicitly said "don't break the history times" :)

I really appreciate your poking at it to confirm my original theory for the activity side; that's quite helpful.

At this point, as you've already tried a good bit to help us, I'd like to setup a replication environment and just sort out a proper fix for you.
I fear it will likely take a couple days and apologize in advance for the delay though.

I'll update you in this thread with my progress.

#9 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 26 February 2014 - 09:20 PM

As an update, I have managed to replicate your issue in a test environment which is proving most helpful.

I'm working on narrowing down the exact issues and coming up with a fix so still be a little bit though.

#10 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 February 2014 - 11:13 PM

Thanks for the update Geoff!

#11 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 27 February 2014 - 10:55 PM

I have a fix we're just code reviewing it.

I should be able to provide you a patch tomorrow.

#12 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 04 March 2014 - 07:46 PM

So... clearly I lied rather egregiously about providing a patch Feb 28!

Apologies I got a bit swamped. Working to get it reviewed and highest anticipation I can get you something by end of day tomorrow (mean it this time).

#13 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 04 March 2014 - 10:22 PM

I have a patch that, in my local instance, fixes your issue. I believe it will fix your instance as well so long as you specify date.timezone in your php.ini.

You have two options to install it you can either edit the file or simply replace it with my updated copy.

The file is:
<swarm-root>/library/P4/Spec/PluralAbstract.php

To edit it starting on line 476 in the dateToTime method replace:
        } catch (\Exception $e) {
            // we tried and failed; just let it use php's default time zone
        }

With:

        } catch (\Exception $e) {
            // we tried and failed; just let it use php's default time zone
            // note when creating a DateTime from a unix timestamp the timezone will
            // be UTC, we need to explicitly set it to the default time zone.
            $date->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
        }


Alternatively, an updated copy of the file can be found at:
http://pastebin.com/KYCmvw60


For our next release, in addition to this fix I'm working on adding some logic to properly extract/convert the p4d timezone returned by p4 info when running on a Windows server.
With that additional change you shouldn't even need to set your date.timezone php.ini setting (though doing so would still be fine).

Thanks for your patience and apologies for the slow fix. Please do update me to indicate if this fixes your issue or not.

#14 mmills

mmills

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 04 March 2014 - 11:00 PM

Great, thanks Geoff! This appears to have resolved the issue.

And believe it or not, I'd consider this a quick fix compared to some of the other software vendors I've worked with. :)

#15 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 05 March 2014 - 12:44 AM

Well we'll try to do better for you in future regardless but I'm always happy to benefit from low expectations :)

Thanks for reporting back it helped.
When our next version comes out it will have a slightly more thorough fix in it so you should just be able to upgrade without issue.

#16 jspang

jspang

    Member

  • Members
  • PipPip
  • 26 posts

Posted 26 March 2014 - 10:19 PM

Hello, I was having the exact same issue as described, but the fix did not seem to work. Let me re-trace what happened:
  • We noticed that the dates in the Activity feed were in UTC
  • I set date.timezone = "America/Vancouver" in my php.ini. Now, the dates in the Activity feed were correct, but the History page dates were off by 7 hours.
  • I added your fix to PluralAbstract.php listed above
Certain pages won't load at all now that I added in the fix (the History page, as well as individual changelist pages). Here is the error I'm seeing in apache's swarm.error_log
PHP Fatal error:  Call to a member function setTimeZone() on a non-object in /opt/swarm-2013.3.762688/library/P4/Spec/PluralAbstract.php on line 480
Did I do something wrong in applying the fix?

#17 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 26 March 2014 - 11:42 PM

View Postjspang, on 26 March 2014 - 10:19 PM, said:

PHP Fatal error: Call to a member function setTimeZone() on a non-object in /opt/swarm-2013.3.762688/library/P4/Spec/PluralAbstract.php on line 480
Did I do something wrong in applying the fix?

Very strange, as they say its not you its me.
I'm surprised this worked for others; perhaps they did what I meant and not what I said.

The modification should actually be done in the timeToDate method _not_ the dateToTime method.
The file is still:
<swarm-root>/library/P4/Spec/PluralAbstract.php

But to edit start on line 455 in the timeToDate method replace:
        } catch (\Exception $e) {
            // we tried and failed; just let it use php's default time zone
        }

With:
        } catch (\Exception $e) {
            // we tried and failed; just let it use php's default time zone
            // note when creating a DateTime from a unix timestamp the timezone will
            // be UTC, we need to explicitly set it to the default time zone.
            $date->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
        }

I have updated the copy hosted at http://pastebin.com/6ttf8Dav with a proper patch if you prefer to simply download the full modified file.


I apologize for the error, the version we're checking into our next release was done correctly but my backport in this instance not so much.

If you still have any difficulties please do let me know.

#18 jspang

jspang

    Member

  • Members
  • PipPip
  • 26 posts

Posted 26 March 2014 - 11:47 PM

Thanks, that did the trick!

#19 P4Geoff

P4Geoff

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts

Posted 26 March 2014 - 11:47 PM

Happy to hear it!

Sorry for the mistake and thanks for including such nice error details it was most assistive.



Also tagged with one or more of these keywords: swarm, activity, time

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users