# Daylight Savings / UTC Timezone Offset

**URL:** <https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729>\
**Category:** C++\
**Tags:** unreal-engine, UE4, UE4-27, CPP, question\
**Created:** [July 19, 2022, 6:47pm UTC](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729 "2022-07-19T18:47:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jo.codegirl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jo.codegirl](https://forums.unrealengine.com/u/jo.codegirl)\
**Post date:** [July 19, 2022, 6:47pm UTC](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729/1 "2022-07-19T18:47:37Z")

</div>

I am looking for a way to determine the UTC Timezone Offset (eg. -7:00) given the local computer settings. FDateTime accounts for daylight savings so it does not give me the correct answer to find the timespan from LocalTime to UTCTime (eg. will give -6). How can I determine whether daylight savings is on?

---

<div class="post-metadata">

**Author:** ![ariveros327](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ariveros327/32/548075_2.png) [@ariveros327](https://forums.unrealengine.com/u/ariveros327)\
**Post date:** [July 19, 2022, 8:34pm UTC](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729/2 "2022-07-19T20:34:17Z")

</div>

Hi , @jo.codegirl, you can get the computer’s datetime with FDateTime:Now(). Also, if you want to have the difference between your pc’s time and the utcDatetime you can do this

```
int utcnow = FDateTime::UtcNow().GetHour();
int now = FDateTime::Now().GetHour();
int diff = now - utcnow;

```

and get the difference in hours. Remember use #include “Misc/DateTime.h”

---

<div class="post-metadata">

**Author:** ![Fire1nRain](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fire1nRain](https://forums.unrealengine.com/u/Fire1nRain)\
**Post date:** [February 23, 2023, 9:02am UTC](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729/3 "2023-02-23T09:02:48Z")

</div>

Hi, We’ve encountered this issue too, and @ariveros327 's answer provided us with a good idea.  
But we have to point out that there’s a bug:  
If it’s 2:00 AM +8, the diff calculated from the method suggested above would give a wrong answer of -16 due to the fact that Utc time is still in the previous day. The better way for doing this is

```auto
auto diff = FDateTime::Now() - FDateTime::UtcNow();
auto hourDiff = diff.GetHours();

```

---

<div class="post-metadata">

**Author:** ![cbsuh.xlgames](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cbsuh.xlgames](https://forums.unrealengine.com/u/cbsuh.xlgames)\
**Post date:** [July 12, 2024, 2:57am UTC](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729/4 "2024-07-12T02:57:04Z")

</div>

Just for your information, there are UTC offsets such as UTC+09:30.  
[Wikipedia: Time zone](https://en.wikipedia.org/wiki/Time_zone)
