Pull partial content of a string variable?

This may sound like a stupid question and probably is… but is there a way to only use partial content of a string variable?

I am pulling a string variable of a date from PlayFab (online services), this returns a date for the end time of a leaderboard, and the string looks like this: 2023-10T00:00:00Z

I want to hook up the date to my UI but i don’t want to type it manually because the reset times will change and never be the same, so i need to somehow format it in a way where i am able to pull only the first part of the string? I Hope this makes sense.

Any ideas ?

I found it. Using the LeftChop or RightChop node from the string and setting the count to the amount of characters to remove.

An alternative way to work with datetime conversions is to build an FDateTime first

FDateTime::Parse | Unreal Engine Documentation

Support for string parsing is not optimal. LeftChop / RightChop assumes there is a constant amount of characters in the string with no option to validate the result. Another risk you take is that the online service always returns this time string. What if some day the server errors and your UI posts an entire error result of the network? It’s just an example but it’s a bad practice to assume external data is formatted properly. In cases it can cause security holes as well.

1 Like

Thanks a lot for this!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.