# How can I get Daylight Savings / UTC Timezone Offset of player's computer?

**URL:** <https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [February 7, 2023, 4:38pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722 "2023-02-07T16:38:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [February 7, 2023, 4:38pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/1 "2023-02-07T16:38:37Z")

</div>

Hi!

I’m using Unreal 5 and I’m trying to get Daylight Savings / UTC Timezone Offset of player’s computer, but I don’t know how to do it.

I’ve been checking `FDateTime`, but I don’t think I can get Daylight Savings / UTC Timezone Offset using it.

Maybe, I have to use some Windows API.

Thanks!

---

<div class="post-metadata">

**Author:** ![rokenrock](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rokenrock/32/1040844_2.png) [@rokenrock](https://forums.unrealengine.com/u/rokenrock)\
**Post date:** [February 7, 2023, 9:49pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/2 "2023-02-07T21:49:49Z")

</div>

You need to use the UTC now node:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/0/4e089dea339ed7530e10cf62c15b2e0159180435.png)

---

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [February 8, 2023, 8:51am UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/3 "2023-02-08T08:51:21Z")

</div>

No. That doesn’t work.

First, this is a C++ question, not a blueprint question.

Second, the UTCNow method returns the UTC time, not the Daylight Savings.

---

<div class="post-metadata">

**Author:** ![rokenrock](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rokenrock/32/1040844_2.png) [@rokenrock](https://forums.unrealengine.com/u/rokenrock)\
**Post date:** [February 8, 2023, 12:36pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/4 "2023-02-08T12:36:03Z")

</div>

My bad, I often don’t read tags, and I completely missed `FDateTime`.

* * *
  

Here is a post:

> [@Daylight Savings / UTC Timezone Offset](https://forums.unrealengine.com/t/daylight-savings-utc-timezone-offset/608729/2):
>
> 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:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [February 8, 2023, 5:26pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/5 "2023-02-08T17:26:55Z")

</div>

Thanks!

I read it before asking this question. That question doesn’t talk about Daylight Savings.

Thanks.

---

<div class="post-metadata">

**Author:** ![MisterPixel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/misterpixel/32/629747_2.png) [@MisterPixel](https://forums.unrealengine.com/u/MisterPixel)\
**Post date:** [August 24, 2023, 12:53pm UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/6 "2023-08-24T12:53:57Z")

</div>

Do a simple subtraction such as (local\_time - UTC\_time) and u’ll get the exact offset from UTC, meaning your local timezone. I needed the same thing and realized how to do it just now in BP, but it’ll work the same in C++.

---

<div class="post-metadata">

**Author:** ![HeellessAchillez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeellessAchillez](https://forums.unrealengine.com/u/HeellessAchillez)\
**Post date:** [August 25, 2023, 7:28am UTC](https://forums.unrealengine.com/t/how-can-i-get-daylight-savings-utc-timezone-offset-of-players-computer/765722/7 "2023-08-25T07:28:59Z")

</div>

If you are looking for UTC offset, then Pixel’s Laboratory’s suggestion works well I think!

However if you are looking to see if the current time zone is on daylight saving time at the time of execution, and if you don’t mind using `c++20` in your project (and using some `std::string`s), perhaps you may have some luck with the `sys_info` struct from the [chrono library](https://en.cppreference.com/w/cpp/chrono/sys_info).

The following prints out “60min” on my system

```auto
#include <chrono>
#include <iostream>

using namespace std::chrono;

int main()
{
    sys_time<system_clock::duration> st = system_clock::now();

    const auto& timeZoneDatabase = get_tzdb();
    const auto& currentZone = timeZoneDatabase.current_zone();
    auto sysInfo = currentZone->get_info(st);

    std::cout << sysInfo.save;

    return 0;
}

```

Note that it returns an std::string. Example taken from [here](https://learn.microsoft.com/en-us/cpp/standard-library/sys-info-struct?view=msvc-170).
