UKismetMathLibrary::GetTotalSeconds
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the total elapsed time of the timespan as a fractional number of seconds, combining all components into one value. This is the most commonly used FTimespan accessor for gameplay timing.
Caveats & Gotchas
- • Returns total seconds across the whole span, not the seconds component. A span of 1 minute 30 seconds returns 90.0, not 30.0. Use FTimespan::GetSeconds() for the component-only value.
- • When working with very long timespans (multiple days), the double precision may not represent individual milliseconds exactly. If sub-second accuracy matters at large scale, query GetTotalMilliseconds and divide by 1000.0 instead.
Signature
static UE_INL_API double GetTotalSeconds( FTimespan A ); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FTimespan | The timespan to query. | — |
Return Type
double Example
Compute how long a player has been in a match C++
FTimespan MatchDuration = FDateTime::UtcNow() - MatchStartTime;
double SecondsPlayed = UKismetMathLibrary::GetTotalSeconds(MatchDuration);
UE_LOG(LogTemp, Log, TEXT("Session: %.1fs"), SecondsPlayed); See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?