0

Are Shotgun servers supposed to be in UTC time?

I thought I remember reading a while back that Shotgun servers used UTC for timestamps.  But when I look at my server at the event logs, all the times recorded appear to be Mountain Time (my time zone).  I don't see anywhere in the site preferences or in my user settings where a timezone is specified.  How does the site know what my local timezone is.  That info isn't sent when logging in, is it?

Also the EventLogEntry entity returns the created_at using a timezone of shotgun_api3.lib.sgtimezone.LocalTimezone object.  Does the API just grab the local time zone from Python?  Is there anyway to retrieve the created_at dates as UTC time?  Or do I just need to manually convert it?

4 comments

  • 0
    Avatar
    Ben Hadden

    Hi Jake,

    Shotgun is reading the timezone of your local machine, so whatever your machine has as local will be what you see in the UI.  Regarding how this shows up in the API and if you can request the UTC version of the time, I'm not sure.  I'll escalate this to a ticket and have someone get back to you on that.

  • 0
    Avatar
    KP

    Jake, 

    This is documented in our API docs: https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Methods#wiki-shotgun

    There is a parameter called "convert_datetimes_to_utc" you can use when instantiating the Shotgun object which will control how datetimes are treated. 

    boolean convert_datetimes_to_utc (default=True)
    Automatically have the API convert datetimes between local time and UTC. Datetimes are stored in the database in UTC. When this parameter is True, it will use local machine settings for timezone and daylight saving time settings in order to convert datetimes to and from UTC. Datetimes that are returned from Shotgun will be converted from UTC to the local time and the datetime object will contain a tzinfo class. Datetimes that are sent to Shotgun will be converted from local time to UTC. If this parameter is False the datetime object returned by Shotgun will be in UTC and will not have a tzinfo class attached. Conversely, datetimes sent to Shotgun will be assumed as UTC and will be stored as such. Make sure the machine the script is running on has the correct timezone and daylight saving time settings.

  • 0
    Avatar
    Jake Wilson

    Thanks Kevin,

    I found that thing in the API shortly after posting this.  Thanks!

  • 0
    Avatar
    Dení C. Gloria

    Hey guys, reading through this thread I was wondering if it is possible to change the time zone manually??

Please sign in to leave a comment.