UKismetMathLibrary::Subtract_DateTimeTimespan
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Subtracts a timespan duration from a date-time value, returning a new FDateTime shifted backward by that amount. Use this to calculate a past point in time relative to a known timestamp.
Caveats & Gotchas
- • Subtracting a span larger than A's distance from the epoch (January 1, 0001) will produce a negative tick count, resulting in an invalid FDateTime. Check IsValid() on the result if inputs are unbounded.
- • This returns a new FDateTime — the original value A is not modified, matching the immutable value-type semantics of FDateTime.
Signature
static UE_INL_API FDateTime Subtract_DateTimeTimespan(FDateTime A, FTimespan B); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FDateTime | The base date and time. | — |
| B | FTimespan | The duration to subtract. | — |
Return Type
FDateTime Example
Calculate the start of a cooldown window C++
FDateTime Now = FDateTime::UtcNow();
FTimespan CooldownDuration = FTimespan::FromSeconds(60.0);
FDateTime CooldownStart = UKismetMathLibrary::Subtract_DateTimeTimespan(Now, CooldownDuration); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?