How to Get Timestamp

Hello, I thought I’d post the answer to this common question I answered for myself.

include “Misc/DateTime.h”
include “HAL/PlatformTime.h”

FDateTime ReturnTimestamp() {
int32 Year, Month, Day, DayOfWeek;
int32 Hour, Minute, Second, Millisecond;
FPlatformTime::SystemTime(Year, Month, DayOfWeek, Day, Hour, Minute, Second, Millisecond);
return FDateTime(Year, Month, Day, Hour, Minute, Second, Millisecond);
}

Below is the documentation for FDateTime. Have fun!

I’ve never posted on here before so the include statements are messed up, but other than that i hope whoever reads this understands and it is of some help to them haha.

Hey there! Thanks for posting this. Please mark your own question / answer as the correct answer or make a new post and mark that as the correct answer so that at a glance people can see this question is actually answered. :wink:

2 Likes