RealDocs

UKismetMathLibrary::ToUnixTimestamp

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

Description

Returns the number of whole seconds elapsed since the Unix Epoch (1970-01-01 00:00:00 UTC). Sub-second precision is truncated.

Caveats & Gotchas

  • FDateTime has no built-in time zone — if you pass a local-time FDateTime instead of a UTC one, the resulting Unix timestamp will be offset by the local UTC offset, making it incorrect when shared with other systems.
  • Sub-second precision is lost because the return type is int64 (whole seconds). Use ToUnixTimestampDouble() if you need millisecond or finer resolution.

Signature

static UE_INL_API int64 ToUnixTimestamp(const FDateTime& Time);

Parameters

Name Type Description Default
Time const FDateTime& The FDateTime to convert.

Return Type

int64

Example

Get current Unix timestamp C++
FDateTime UtcTime = UKismetMathLibrary::UtcNow();
int64 UnixTs = UKismetMathLibrary::ToUnixTimestamp(UtcTime);
UE_LOG(LogTemp, Log, TEXT("Unix timestamp: %lld"), UnixTs);

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.