RealDocs

UKismetMathLibrary::UtcNow

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPure

Description

Returns the current UTC date and time. Use this instead of Now() whenever timestamps need to be consistent across machines or time zones.

Caveats & Gotchas

  • FDateTime has no embedded time zone field — there is no way to tell from the value itself whether it stores UTC or local time. By convention, document which your variables hold and be consistent.
  • Comparing UtcNow() with a value obtained from Now() on a non-UTC machine will give an incorrect time difference equal to the UTC offset of the local machine.

Signature

static UE_INL_API FDateTime UtcNow( );

Return Type

FDateTime

Example

Stamp a network event with UTC time C++
FDateTime EventTime = UKismetMathLibrary::UtcNow();
int64 UnixTs = UKismetMathLibrary::ToUnixTimestamp(EventTime);
// Send UnixTs over the network for consistent comparison on all clients

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.