How to set default value of DateTime Struct?

I’m trying to set default value of a DateTime Struct, but that’s not possible. default default value is “0001.01.01-00.00.00” and if I change it to “2000.01.01-00.00.00” and hit Compile, it changes back to “0001.01.01-00.00.00”.
Unfortunately I also can’t find any node for directly setting DateTime value.
I don’t care how, I just want to set this Date once to date I need it to be, if you have any idea I would appreciate some hints how to do this

4.6.1, last stable version

Hey

Which version are you working in?

So I have a similar experience as you do. During my time searching why that is I found this on AnswerHub where someone describes in a fashion how to manipulate DateTime https://answers.unrealengine.com/questions/124364/keeping-track-of-playtime.html

Hope it helps otherwise I would need to know what you would like to achieve by setting this to a higher value.

Best

I know this way to manipulate DateTime, but it does only work for short periods of time. I need to set my time to something like January 1. 1200, it’s a medieval game and I want to show Date :slight_smile:

Hi ,

This issue just popped up in my list, so I’m not sure how it was overlooked but I apologize.

Testing this in 4.7.3, it appears to no longer be an issue. I’m able to set default of a variable of type DateTime within struct.

To update a struct value, use the “Set members in StructName” node, where “StructName” is name of your structure. You can then get a reference to Struct and set its DateTime member variable with a DateTime variable in BP. Currently, there’s a bug in 4.7.3 that does crashes editor if there’s a DateTime variable in a Blueprint, but it’s integrated into 4.7.4 (and should be available in latest 4.7 branch if you’re building from GitHub).

Hope that helps!

You don’t have to apologize, I just moved this question to Bug Reports recently :wink:
Actually I don’t get what you want to say with “To update a struct value, use the “Set members in StructName” node, where “StructName” is name of your structure”. There is no “Set members in DateTime” or am I blind?

I have no struct, why do you think I have a struct? I am just talking about a single DateTime variable, which is itself a struct. My question is how to set a single DateTime variable.

It will be name of your struct instead of “DateTime.” So if your struct with DateTime variable is named “DateTimeStruct,” you would search for node called, “Set members in DateTimeStruct.” If you search only for “Set members in” in context menu, you should see every struct in your project show up as an option and you can simply select correct one.

It’s possible you’ll need to compile/save struct again before it shows up in menu. I’m not sure whether that’s a bug or I just forgot to do it, but that happened to me once. I’ll be looking into that separately.

I’m sorry, I was thrown off by your terminology. We usually refer to DateTime Structure variables as DateTime variables, so I assumed you made a Struct using DateTime variables.

I’m looking into this now. build I had from GitHub was old and fix for DateTime variable crash wasn’t included, so it’ll take a bit to build current. I’ll let you know how to set this up once I have everything up to date.

Okay, just double checked in latest 4.7, and setting default for a DateTime variable does work (it doesn’t reset when compiling), and having one in your BP no longer crashes editor. As for setting one during runtime, it looks like that’s not actually possible. I’m going to enter a feature request for that, and I’ll let you know what developers say when they get to it.

Unfortunately it is NOT fixed. I am using 4.7 branch from github (some days old, 4.7.3 + 11 commits) and I can use DateTime variables without crashes. I set it to “1100.01.01-00.00.00” default value (medieval game). Then i start game and print it out. And unfortunately I get " Aug 12, 1916" which is not very medieval.

Ah, okay, that looks like a separate issue. FDateTime isn’t correctly formatted by string converter when using any dates before January 1st, 1970, so using As Date Time nodes to print DateTime variable won’t work for anything before then. ICU based string formatter converts FDateTime to a unix timestamp, which is then formatted as a string. January 1st 1970, is when Unix epoch starts, thus limitation.

I’ve entered a bug report for that (UE-13006) and I’ll let you know when I see an update. Thanks for report!