# How to compare two dates? (How to set an Expiration date)

**URL:** <https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [May 24, 2023, 10:21am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902 "2023-05-24T10:21:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel1900](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/miguel1900/32/1010694_2.png) [@Miguel1900](https://forums.unrealengine.com/u/Miguel1900)\
**Post date:** [May 24, 2023, 10:21am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/1 "2023-05-24T10:21:28Z")

</div>

Hi all!

I would want to ask you for the best way to compare two dates inside Unreal, please.

The objetive is to set one date into a variable and compare the current actual date, to know if that initial date is more recent or older than the current time (date).

Summary: I wan’t to stablish an expiration date for my application.

Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 24, 2023, 10:38am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/2 "2023-05-24T10:38:36Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/d/64da929c0a4100f441908d259c259ab30d89b2ba.png)

Look into DateTime. This will expire for me in about 5 mins:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/2/442802c017d21df3ecd2cd02ccf10f3b7c3a5081.png)

---

<div class="post-metadata">

**Author:** ![Miguel1900](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/miguel1900/32/1010694_2.png) [@Miguel1900](https://forums.unrealengine.com/u/Miguel1900)\
**Post date:** [May 24, 2023, 10:55am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/3 "2023-05-24T10:55:50Z")

</div>

Oh, thank you so much @Everynone ! I didn’t think about those math symbols working with time structures 🙂

I would want to ask you an additional question, please: any idea about getting the date from the internet? (Currently, expiration date can be bypassed changing the SO date)

Thank you!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 24, 2023, 11:08am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/4 "2023-05-24T11:08:21Z")

</div>

Honestly, I do not know but as soon as I start searching, I get results:

> [@Get date online](https://forums.unrealengine.com/t/get-date-online/358960):
>
> Hi all, I’m developing a game for android and I want to implement a daily reward, my question is, is there any way to get the date from an external web site or any other site?, because using the local date is easy to change it.

With enough digging, I am almost sure you can find it. Or try marketplace plugins. Or wait until someone more knowledgeable chips in!

---

<div class="post-metadata">

**Author:** ![Miguel1900](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/miguel1900/32/1010694_2.png) [@Miguel1900](https://forums.unrealengine.com/u/Miguel1900)\
**Post date:** [May 24, 2023, 11:13am UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/5 "2023-05-24T11:13:28Z")

</div>

Thank you again @Everynone ,

Certainly I didn’t search for it. I just asked because of the adrenalin replying the previous post. (Not as the first question, which I tried to find in Google, of course).

Don’t worry. The main and most important part is already achieved with your advice.

Thanks!

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [May 24, 2023, 1:02pm UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/6 "2023-05-24T13:02:54Z")

</div>

I would probably put up a custom server (php, c#, java whatever you are comfortable with) and expose the date via an api through JSON. (just do an encoding of current datetime with the needed daylight saving + - x hours depending on time zone)

You could go with a free service but if it’s critical for license expiration etc  
then I wouldn’t recommend it.

> <https://stackoverflow.com/questions/13240530/free-rest-api-to-retrieve-current-datetime-as-string-timezone-irrelevant>

---

<div class="post-metadata">

**Author:** ![Miguel1900](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/miguel1900/32/1010694_2.png) [@Miguel1900](https://forums.unrealengine.com/u/Miguel1900)\
**Post date:** [May 24, 2023, 6:14pm UTC](https://forums.unrealengine.com/t/how-to-compare-two-dates-how-to-set-an-expiration-date/1176902/7 "2023-05-24T18:14:37Z")

</div>

Thank you @3dRaven !

Currently testing with one of the free and working fine, with the help of the plugin VaRest too.

Thanks! 🙂
