# Query Results in Local Timezone?

**URL:** <https://community.shiphero.com/t/query-results-in-local-timezone/2437>\
**Category:** GraphQL API\
**Created:** [April 12, 2023, 8:11pm UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437 "2023-04-12T20:11:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Raj](https://community.shiphero.com/u/Raj)\
**Post date:** [April 12, 2023, 8:11pm UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437/1 "2023-04-12T20:11:37Z")

</div>

Hi,  
I have to convert all my time based API queries to UTC and the results are also received only in UTC.  
Is there any way to have them in local timezone (we have set the correct local timezone in SH site settings)?

I can live with having to send queries in UTC (though not ideal), but receiving results and then having to convert every single line entry in every single query is insane - can you pls suggest a solution?

Thank you  
Raj

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [April 13, 2023, 11:04am UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437/2 "2023-04-13T11:04:09Z")

</div>

Hey @Raj,

Thanks for reaching out.  
I’ll look into this and let you know if there’s anything that can be done.

Please let me know if you have any questions or concerns.

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![Raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Raj](https://community.shiphero.com/u/Raj)\
**Post date:** [April 14, 2023, 6:54pm UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437/3 "2023-04-14T18:54:41Z")

</div>

Hey @sh-agent, were you able to find out more here?  
Thank you!

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [April 17, 2023, 6:40pm UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437/4 "2023-04-17T18:40:53Z")

</div>

Hey @Raj,

Thanks for hanging in there while I looked into this.

Unfortunately, I wasn’t able to find a solution on our end to change the queried results to the users native timezone.

Please let me know if you have any questions or concerns.

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![hansdaigle](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/hansdaigle/32/369_2.png) [@hansdaigle](https://community.shiphero.com/u/hansdaigle)\
**Post date:** [May 10, 2023, 7:28pm UTC](https://community.shiphero.com/t/query-results-in-local-timezone/2437/5 "2023-05-10T19:28:54Z")

</div>

You can do this automatically in Pyhton using a pydantic validator:

For example:

```auto
from datetime import datetime, timezone
from pydantic import BaseModel, validator
...

class MyModel(BaseModel):
    allocated_at: datetime

    @validator('allocated_at')
    def assign_utc_timezone(cls, value):
        return value.replace(tzinfo=timezone('UTC'))

```

Then all your datetime objects are timezone aware and it’s easy to convert to your local time. For example using pendulum:

```auto
import pendulum
# Can be done in one line as well
allocated_at = pendulum.instance(datetime_obj_to_convert)
local_allocated_at = allocated_at.in_timezone('America/New_York')

```
