How to get game's build/package date not engines?

If I use FApp::GetBuildDate(); aka __DATE__ I’m given the date when the core engine was built and not when my game was built, cooked, and packaged.

Is the build “Package & Cook” date available somewhere in the engine?

I’ve been looking but can’t seem to find anything that would suffice. We use the engine as-is and don’t want to perform a source build just to get the macro timestamped.

Getting the exact build or “Package & Cook” date of your game directly using built-in functions or variables isn’t straightforward if you are using the precompiled binaries of the engine (as it sounds like you are). This is primarily because, as you noted, the FApp::GetBuildDate() function returns the build date of the engine itself, not of your specific project or its cooking session.

There is a couple of options you can try…

1. Automation Scripting

One common approach is to use Unreal Engine’s automation tools (like Unreal Build Tool or UBT) and scripting to generate a build timestamp during the cook and package process. You can write a simple script that runs as part of your build process, which writes the current date and time to a file or directly into a code file as a static variable.

For example, you can add a step in your build pipeline (using a batch file, shell script, or custom build step in your IDE) that writes the current build timestamp to a config file or directly into a header file that your Unreal project can read from.

2. Pre-Build Events

Use pre-build events in your project’s build configuration to execute a command line script that will generate a header file or update a configuration file with the current date and time. Here’s a simple example using a batch file for a Windows build:

echo #define BUILD_TIMESTAMP "%DATE% %TIME%" > Config/BuildTimestamp.h

Then, in your game code, you can include BuildTimestamp.h and use the BUILD_TIMESTAMP macro where needed.

3. Blueprints

If you prefer not to involve C++ and are working mostly in Blueprints, you can create a custom Blueprint node using a C++ function that reads the system date and time at runtime and formats it as a string. This won’t give you the build date but the date when the game was launched, which might still be useful depending on your needs.

4. Third-Party Tools

Consider using third-party build automation tools like Jenkins, TeamCity, or GitLab CI/CD, which can automate the process of injecting build timestamps into your game files. These tools can set environment variables or modify game files at build time, which your game can then access to display the build date.

5. Post-Build Tools

After the build, use a custom tool to modify the packaged game’s files. For example, a simple tool could modify a JSON or XML file inside the packaged game’s content folder with the current date and time after the build completes.

Implementation in C++

If you decide to use a C++ approach, you could add a static class or namespace in your game’s source code that holds the build timestamp:

namespace BuildInfo
{
    static const FString BuildTimestamp = TEXT("Build timestamp not set");
}

And during the build process, overwrite this file or variable with the current timestamp.

Hope this helps.

Yeah, i figured I’d likely need to implement a build event macro. Just hoping i had overlooked something simple that was already inside the engine.

Thank you for the detailed reply. I’ll likely use the pre-build configured macro as once the hooks are in place It’d be trivial to support any other metadata.

1 Like

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