UKismetMathLibrary::GetHour
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the hour component of A in 24-hour format (0–23). Use this for time-of-day logic such as gating game events to certain hours.
Caveats & Gotchas
- • Returns hours in 24-hour (military) time. Hour 0 is midnight, hour 12 is noon, hour 23 is 11 PM. Use GetHour12 if you need 12-hour clock format for UI display.
- • The hour is extracted from the stored tick count with no daylight-saving or timezone conversion. If A is a UTC timestamp and the local timezone observes DST, the displayed hour will differ from what the local clock shows.
Signature
static UE_INL_API int32 GetHour( FDateTime A ); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FDateTime | The date-time to extract the hour from. | — |
Return Type
int32 Example
Restrict an online event to business hours C++
FDateTime Now = FDateTime::UtcNow();
int32 Hour = UKismetMathLibrary::GetHour(Now);
bool bBusinessHours = (Hour >= 9 && Hour < 17); // 09:00–17:00 UTC Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?