RealDocs

UKismetMathLibrary::GetSecond

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

Description

Returns the second component of A in the range 0–59. Use this for displaying or comparing time at second precision.

Caveats & Gotchas

  • This is the second within the current minute (0–59), not total elapsed seconds since epoch. For total elapsed seconds use Subtract_DateTimeDateTime and call FTimespan::GetTotalSeconds() on the result.
  • Sub-second precision (milliseconds, microseconds) is lost. For timing purposes that require better than one-second resolution, work with FTimespan::GetTotalSeconds() (which returns a double) or FDateTime::GetTicks() directly.

Signature

static UE_INL_API int32 GetSecond( FDateTime A );

Parameters

Name Type Description Default
A FDateTime The date-time to extract the second from.

Return Type

int32

Example

Display a countdown timer C++
FDateTime Deadline = GetDeadline();
FDateTime Now = FDateTime::UtcNow();
FTimespan Remaining = UKismetMathLibrary::Subtract_DateTimeDateTime(Deadline, Now);
int32 SecondsLeft = FMath::Max(0, (int32)Remaining.GetTotalSeconds());
FString Countdown = FString::Printf(TEXT("%d seconds remaining"), SecondsLeft);

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.