Datetime from Shotgun Server

Hi,

I need to compare a local dateime with server’s current system datetime.
Is there any way to get shotgun’s system time in python script?

Thanks!

Jonghan

2 Likes

Hey Jonghan - I don’t know if there’s a way to get the datetime via python, but all of our servers are in UTC, if that helps.

1 Like

Thanks Mason, I know it.
but I need to know in the script whether the local computer time is not corrupted.
Because I want to write a function for expiration of the script, I need to use server time than local computer’s time.
Even I can get the absolute time from the other servers, it must be the best to bring it from Shotgun server.

Thanks!
Jonghan

1 Like

Hi Jonghan,

When querying for/setting datetime fields in Shotgun, we’re doing an automatic conversion for you to the local timezone of the system doing the requests. So while we’re storing everything as UTC, every date you send/receive from the server will always be in the local timezone of the system.

So to get the true stored UTC value you’d need to do your own conversion to UTC after requesting the value of a datetime field from Shotgun.

3 Likes

There’s some Python hints about dealing with UTC and local time in the API code at Shotgun API at GitHub

4 Likes

Yes! I sounds great. will do it. Thanks.

1 Like

I just created a “Version” row and queried its “created_at” field. After refer to it deleted it.

Thanks!

jonghan

2 Likes