Download

FDateTime::Now() is returning the wrong time and date

Hi, so FDateTime::Now() is the source, then I FText::AsDateTime() and FText::AsDate() for a couple of timestamp entries, they are returning strigns as if FDateTime::Now() was fetching the UTC time but the docs say that Now() fetches the local time.

I did some google legwork and it seems there were known bugs with FText::AsDate() and others back in 2014, have they not been fixed yet?

So the FDateTime::Now() is the correct time and it is the FText::As*****() times and dates that are wrong,

Some more information, this code

FDateTime CurrentDateTime = FDateTime::Now();
UE_LOG(LogTemp, Log, TEXT("%s"), *CurrentDateTime.ToString());
FText TimeStamp = FText::AsDateTime(CurrentDateTime, EDateTimeStyle::Short, EDateTimeStyle::Medium);
UE_LOG(LogTemp, Log, TEXT("%s"), *TimeStamp.ToString());
FText DateStamp = FText::AsDate(CurrentDateTime, EDateTimeStyle::Long);
UE_LOG(LogTemp, Log, TEXT("%s"), *DateStamp.ToString());

This output was generated on 15th October at 6 mins past 9pm,

LogTemp: 2019.10.15-21.06.22
LogTemp: 16/10/19 10:06:22 am
LogTemp: 16 October 2019

My time zone is UTC+12, so it looks liek FText::AS…() functions are adding the time zone to the Now() time, but Now() has already taken timezone into account, how do I get them to format with the actual time from Now()?

Think I have found the solution

https://answers.unrealengine.com/questions/455405/fdatetime-ftext-broken-tostring-reports-correct-ti.html?sort=oldest