RealDocs

UKismetMathLibrary::FromSeconds

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

Description

Constructs an FTimespan from a number of seconds. The most frequently used FTimespan factory in gameplay code because most engine APIs expose durations in seconds.

Caveats & Gotchas

  • When bridging from UWorld::GetTimeSeconds (a float in older projects), note that float precision limits accuracy to roughly ±16 million seconds (~6 months). Cast to double before passing to avoid rounding that accumulates over long sessions.
  • FromSeconds does not clamp the input — supplying a NaN or infinity from a bad calculation will produce an invalid FTimespan whose tick value is implementation-dependent. Validate inputs from external sources.

Signature

static ENGINE_API FTimespan FromSeconds(double Seconds );

Parameters

Name Type Description Default
Seconds double Number of seconds (may be fractional).

Return Type

FTimespan

Example

Create a cooldown timespan from a data asset field C++
// AbilityData.CooldownSeconds is a float from a data asset
FTimespan Cooldown = UKismetMathLibrary::FromSeconds(static_cast<double>(AbilityData.CooldownSeconds));
FDateTime ReadyAt = FDateTime::UtcNow() + Cooldown;

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.