FDateTime FText broken, ToString() reports correct time, FText reports wrong time

Dear Epic,

I know this issue was discussed a few years ago but it still persists.

The FText variants of FDateTime are simply inaccurate.

I’ve attached a picture where I just tested both the ToString() and the FText variants of the UTC and my local time.

The FText variants are both wrong!

My actual local time is 11:36:25pm EDT, but FText thinks local time is 6:36:25 and that the UTC time is 10:36:25, which doesnt make any sense at all because my time zone is UTC -5, and that is a 4 hour time difference, let alone the fact that the UTC time is itself wrong.

Can you please fix FText of FDateTime?

Here again is the code that is in the picture:

FDateTime UTC = FDateTime::UtcNow();
FDateTime LOCALEDT = FDateTime::Now();

V_LOGE2("UTC ~", UTC.ToString());
V_LOGE2("Local(EDT) ~", LOCALEDT.ToString());
	 
FText TimeStampUTC = FText::AsDateTime(UTC, 
	EDateTimeStyle::Long, 	//date
	EDateTimeStyle::Medium 			//time
);
FText TimeStamp = FText::AsDateTime(LOCALEDT, 
	EDateTimeStyle::Long, 	//date
	EDateTimeStyle::Medium 			//time
);
V_LOGE2("UTC FText ~", TimeStampUTC.ToString());
V_LOGE2("Local(EDT) FText ~", TimeStamp.ToString());

Thank youuuu!

#:heart:

Rama

#The Solution

Sooo, it turns out there is this extra parameter that I really think should be the default value, that makes the times work out correctly. :slight_smile:

#GetInvariantTimeZone()

:heart: Rama

1 Like

#PR submitted on Github

https://github.com/EpicGames/UnrealEngine/pull/2612

#PR submitted on Github

https://github.com/EpicGames/UnrealEngine/pull/2612

Thank you ! It’s solved my problem !!!