UKismetMathLibrary::DaysInMonth
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns the number of days in a given month, correctly accounting for leap years when Month is 2 (February). Delegates to FDateTime::DaysInMonth().
Caveats & Gotchas
- • Passing Month outside [1, 12] or Year outside [1, 9999] triggers a check failure in Debug/Development builds via ReportError_DaysInMonth(). In Shipping the result is undefined.
- • February returns 28 or 29 — you must pass the actual year for correct results. Passing Year=0 or a bogus year gives wrong leap-year answers.
Signature
static UE_INL_API int32 DaysInMonth( int32 Year, int32 Month ); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Year | int32 | The year (1–9999), required to handle February in leap years. | — |
| Month | int32 | The month number (1 = January … 12 = December). | — |
Return Type
int32 Example
Build a calendar month grid C++
int32 Year = 2024;
int32 Month = 2; // February
int32 Days = UKismetMathLibrary::DaysInMonth(Year, Month);
// Days == 29 (2024 is a leap year) Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?