Having troubles with DateTime in UE5

Hello devs!

I have a silly problem with time in UE5, and I was hoping you could help me figure out a solution for my problem.

I am currently saving some gameplay sessions with DateTime.Now(). On a later stage, I need to filter out these sessions by time, as I can have my user pick a random interval in a range (1 day, 3 days, 7 days, 14 days, and so on). This was quite straightforward with DateTime operations in UE4, I could have a subtract operation and be done in a second. However, they are currently not working in UE5 preview, I tried to subtract DateTime structs and it simply doesn’t connect the variables with the node itself.

A perfect solution for me would be to use an ISO date, but as far as I know I can only convert from string to DateTime, not the other way around, and I am not sure if I can manually convert it myself.

Is there any solution that comes to your mind? I know I could write the logic to subtract DateTimes myself, but I’d rather avoid that.

Best!

I’m having the same problem. I have a past DateTime value, and I want to find the difference from DateTime.Now(). How can such a simple thing be impossible in UE5? Internally, they’re just numbers (seconds since epoch start).

Edit: After creating a generic Subtract node, then manually converting the pins to Date Time structs, I get a green checkmark when dragging a DateTime pin over an input. When I release left-click, it fails to connect, and the input pins become Timespan structs instead. However, if I drag to the lower pin first, then the top pin becomes a DateTime struct, while the lower pin becomes a Timespan struct. This allows me to connect a DateTime value to the top pin, while I still can’t connect another DateTime to the lower pin.

Also, Timespan pins cannot be converted to any other type. A fresh node must be created to try again. Definitely buggy.

I filed a bug report, and a dev replied that this is a known, backlogged bug. It is currently not a priority.

Old Math Node: ‘UE4 Ctrl+C’ → ‘UE5 CTRL+V’ :smiling_face_with_tear:

4 Likes

…I can’t believe that… :rage:

1 Like

Clever! here’s the text based version so you can copy/paste this:

Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_18"
   bIsPureFunc=True
   FunctionReference=(MemberParent=Class'"/Script/Engine.KismetMathLibrary"',MemberName="Subtract_DateTimeDateTime")
   NodePosX=0
   NodePosY=0
   NodeGuid=8DF6E69546B319D0DEE8F7920E91D78B
   CustomProperties Pin (PinId=1A250D1E4FB1C43E3D0D498086F9A06C,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.KismetMathLibrary"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,DefaultObject="/Script/Engine.Default__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=94AA18E74C77A6C3AD17D8B7C12893D9,PinName="A",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.DateTime"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,LinkedTo=(K2Node_CallFunction_17 4485BCFD43F6B8E49F2B1CB2C1FECE4B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=BC81FBF0483C71486EA364A71267A24B,PinName="B",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.DateTime"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=E791466840C71DCF3E0B4A89BC5994DA,PinName="ReturnValue",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.Timespan"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
8 Likes

Same issue almost a year later… Any known workarounds?

Select all the text in the box in the post above this (Text Based Version), ctrl+C, then ctrl+V into your blueprint…

2 Likes

Wow, still an issue. Thanks for the text to copy/paste as the work around!

2 Likes

How is this still not fixed in 5.2? Pretty nuts. But thanks for the copy/paste!

Ridiculous this is still not fixed, yet, after more over 2 years…

@RecourseDesign, thank you very much for the tip and the provided c/p

2 Likes

That’s so nice! I copy here the ADD node, which also causes problems, at least to me, just in case someone needs it.

Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_1"
   bIsPureFunc=True
   FunctionReference=(MemberParent=Class'"/Script/Engine.KismetMathLibrary"',MemberName="Add_DateTimeDateTime")
   NodePosX=768
   NodePosY=496
   NodeGuid=A88E194C41CBDDB37BBF6280BEAEEC29
   CustomProperties Pin (PinId=CAB55EEB4B130D019609D8AD54D0BDD4,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet Math Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.KismetMathLibrary"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,DefaultObject="/Script/Engine.Default__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=857A1C2F445DFD69E1969E8BD73A4886,PinName="A",PinToolTip="A\nDate Time Structure",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.DateTime"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=AAA5619943B3A5326D91D2B7E7A5004B,PinName="B",PinToolTip="B\nDate Time Structure",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.DateTime"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=682CD96144DF5017A1FA41A0F78D47A2,PinName="ReturnValue",PinToolTip="Return Value\nDate Time Structure\n\nAddition (A + B)",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.DateTime"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object

Cheers for this! This was a lifesaver for my project

1 Like