![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <DateTime.h>
Static Public Member Functions | |
| static CORE_API int32 | DaysInMonth (int32 Year, int32 Month) |
| static CORE_API int32 | DaysInYear (int32 Year) |
| static FDateTime | FromJulianDay (double JulianDay) |
| static FDateTime | FromUnixTimestamp (int64 UnixTime) |
| static FDateTime | FromUnixTimestampDecimal (double UnixTime) |
| static CORE_API bool | IsLeapYear (int32 Year) |
| static FDateTime | MaxValue () |
| static FDateTime | MinValue () |
| static CORE_API FDateTime | Now () |
| static CORE_API bool | Parse (const FString &DateTimeString, FDateTime &OutDateTime) |
| static CORE_API bool | ParseHttpDate (const FString &HttpDate, FDateTime &OutDateTime) |
| static CORE_API bool | ParseIso8601 (const TCHAR *DateTimeString, FDateTime &OutDateTime) |
| static FDateTime | Today () |
| static CORE_API FDateTime | UtcNow () |
| static CORE_API bool | Validate (int32 Year, int32 Month, int32 Day, int32 Hour, int32 Minute, int32 Second, int32 Millisecond) |
Static Protected Attributes | |
| static const int32 | DaysPerMonth [] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } |
| static const int32 | DaysToMonth [] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 } |
| static const TCHAR * | ShortDayNames [] = { TEXT("Mon"), TEXT("Tue"), TEXT("Wed"), TEXT("Thu"), TEXT("Fri"), TEXT("Sat"), TEXT("Sun") } |
| static const TCHAR * | LongDayNames [] = { TEXT("Monday"), TEXT("Tuesday"), TEXT("Wednesday"), TEXT("Thursday"), TEXT("Friday"), TEXT("Saturday"), TEXT("Sunday") } |
| static const TCHAR * | ShortMonthNames [] = { TEXT("Jan"), TEXT("Feb"), TEXT("Mar"), TEXT("Apr"), TEXT("May"), TEXT("Jun"), TEXT("Jul"), TEXT("Aug"), TEXT("Sep"), TEXT("Oct"), TEXT("Nov"), TEXT("Dec") } |
| static const TCHAR * | LongMonthNames [] = { TEXT("January"), TEXT("February"), TEXT("March"), TEXT("April"), TEXT("May"), TEXT("June"), TEXT("July"), TEXT("August"), TEXT("September"), TEXT("October"), TEXT("November"), TEXT("December") } |
Friends | |
| struct | Z_Construct_UScriptStruct_FDateTime_Statics |
| FArchive & | operator<< (FArchive &Ar, FDateTime &DateTime) |
| void | operator<< (FStructuredArchive::FSlot Slot, FDateTime &DateTime) |
| uint32 | GetTypeHash (const FDateTime &DateTime) |
Implements a date and time.
Values of this type represent dates and times between Midnight 00:00:00, January 1, 0001 and Midnight 23:59:59.9999999, December 31, 9999 in the Gregorian calendar. Internally, the time values are stored in ticks of 0.1 microseconds (= 100 nanoseconds) since January 1, 0001.
To retrieve the current local date and time, use the FDateTime.Now() method. To retrieve the current UTC time, use the FDateTime.UtcNow() method instead.
This class also provides methods to convert dates and times from and to string representations, calculate the number of days in a given month and year, check for leap years and determine the time of day, day of week and month of year of a given date and time.
The companion struct FTimespan is provided for enabling date and time based arithmetic, such as calculating the difference between two dates or adding a certain amount of time to a given date.
Ranges of dates and times can be represented by the FDateRange class.
|
inline |
Default constructor (zero initialization).
|
inline |
Creates and initializes a new instance with the specified number of ticks.
| InTicks | The ticks representing the date and time. |
| FDateTime::FDateTime | ( | int32 | Year, |
| int32 | Month, | ||
| int32 | Day, | ||
| int32 | Hour = 0, |
||
| int32 | Minute = 0, |
||
| int32 | Second = 0, |
||
| int32 | Millisecond = 0 |
||
| ) |
Creates and initializes a new instance with the specified year, month, day, hour, minute, second and millisecond.
| Year | The year. |
| Month | The month. |
| Day | The day. |
| Hour | The hour (optional). |
| Minute | The minute (optional). |
| Second | The second (optional). |
| Millisecond | The millisecond (optional). |
Gets the number of days in the year and month.
| Year | The year. |
| Month | The month. |
Gets the number of days in the given year.
| Year | The year. |
| bool FDateTime::ExportTextItem | ( | FString & | ValueStr, |
| FDateTime const & | DefaultValue, | ||
| UObject * | Parent, | ||
| int32 | PortFlags, | ||
| UObject * | ExportRootScope | ||
| ) | const |
Exports the date and time value to a string.
| ValueStr | Will hold the string value. |
| DefaultValue | The default value. |
| Parent | Not used. |
| PortFlags | Not used. |
| ExportRootScope | Not used. |
Returns the proleptic Gregorian date for the given Julian Day.
| JulianDay | The Julian Day. |
Returns the date from Unix time (seconds from midnight 1970-01-01)
| UnixTime | Unix time (seconds from midnight 1970-01-01) |
Returns the date from Unix time (seconds from midnight 1970-01-01)
| UnixTime | Unix time (seconds from midnight 1970-01-01) |
|
inline |
Gets the date part of this date.
The time part is truncated and becomes 00:00:00.000.
Gets the date components of this date.
| OutYear | Will contain the year. |
| OutMonth | Will contain the number of the month (1-12). |
| OutDay | Will contain the number of the day (1-31). |
| int32 FDateTime::GetDay | ( | ) | const |
| EDayOfWeek FDateTime::GetDayOfWeek | ( | ) | const |
Calculates this date's day of the week (Sunday - Saturday).
| int32 FDateTime::GetDayOfYear | ( | ) | const |
Gets this date's day of the year.
|
inline |
Gets this date's hour part in 24-hour clock format (0 to 23).
| int32 FDateTime::GetHour12 | ( | ) | const |
|
inline |
Returns the Julian Day for this date.
The Julian Day is the number of days since the inception of the Julian calendar at noon on Monday, January 1, 4713 B.C.E. The minimum Julian Day that can be represented in FDateTime is 1721425.5, which corresponds to Monday, January 1, 0001 in the Gregorian calendar.
|
inline |
|
inline |
|
inline |
Returns the Modified Julian day.
The Modified Julian Day is calculated by subtracting 2400000.5, which corresponds to midnight UTC on November 17, 1858 in the Gregorian calendar.
| int32 FDateTime::GetMonth | ( | ) | const |
|
inline |
Gets the date's month of the year (January to December).
|
inline |
|
inline |
Gets this date's representation as number of ticks.
|
inline |
Gets the time elapsed since midnight of this date.
| int32 FDateTime::GetYear | ( | ) | const |
| bool FDateTime::ImportTextItem | ( | const TCHAR *& | Buffer, |
| int32 | PortFlags, | ||
| UObject * | Parent, | ||
| FOutputDevice * | ErrorText | ||
| ) |
Imports a date and time value from a text buffer.
| Buffer | The text buffer to import from. |
| PortFlags | Not used. |
| Parent | Not used. |
| ErrorText | The output device for error logging. |
|
inline |
Gets whether this date's time is in the afternoon.
Checks whether the given year is a leap year.
A leap year is a year containing one additional day in order to keep the calendar synchronized with the astronomical year. All years divisible by 4, but not divisible by 100 - except if they are also divisible by 400 - are leap years.
| Year | The year to check. |
|
inline |
Gets whether this date's time is in the morning.
Returns the maximum date value.
The maximum date value is December 31, 9999, 23:59:59.9999999.
Returns the minimum date value.
The minimum date value is January 1, 0001, 00:00:00.0.
| bool FDateTime::NetSerialize | ( | FArchive & | Ar, |
| class UPackageMap * | Map, | ||
| bool & | bOutSuccess | ||
| ) |
Serializes this date and time for network transmission
|
static |
Gets the local date and time on this computer.
This method takes into account the local computer's time zone and daylight saving settings. For time zone independent time comparisons, and when comparing times between different computers, please use UtcNow() instead.
Compares this date with the given date for inequality.
| Other | The date to compare with. |
Returns result of adding the given time span to this date.
Returns time span between this date and the given date.
Returns result of subtracting the given time span from this date.
Checks whether this date is less than the given date.
| Other | The date to compare with. |
Checks whether this date is less than or equal to the given date.
| Other | The date to compare with. |
Compares this date with the given date for equality.
| Other | The date to compare with. |
Checks whether this date is greater than the given date.
| Other | The date to compare with. |
Checks whether this date is greater than or equal to the date span.
| Other | The date to compare with. |
Converts a string to a date and time.
Currently, the string must be in the format written by either FDateTime.ToString() or FTimeStamp.TimestampToFString(). Other formats are not supported at this time.
| DateTimeString | The string to convert. |
| OutDateTime | Will contain the parsed date and time. |
Parses a date string in HTTP-date format (rfc1123-date | rfc850-date | asctime-date) https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
HTTP-date = rfc1123-date | rfc850-date | asctime-date rfc1123-date = wkday "," SP date1 SP time SP "GMT" rfc850-date = weekday "," SP date2 SP time SP "GMT" asctime-date = wkday SP date3 SP time SP 4DIGIT date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) date3 = month SP (2DIGIT | (SP 1DIGIT)) ; month day (e.g., Jun 2) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" weekday = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
| HttpDate | The string to be parsed |
| OutDateTime | FDateTime object (assumes UTC) corresponding to the input string. |
Parses a date string in ISO-8601 format.
| DateTimeString | The string to be parsed |
| OutDateTime | FDateTime object (in UTC) corresponding to the input string (which may have been in any timezone). |
Serializes this date and time from or into the specified archive.
| Ar | The archive to serialize from or into. |
| FString FDateTime::ToFormattedString | ( | const TCHAR * | Format | ) | const |
Returns the string representation of this date.
Uses strftime-like syntax: a - Weekday, eg) Sun A - Weekday, eg) Sunday w - Weekday, 0-6 (Sunday is 0) y - Year, YY Y - Year, YYYY b - Month, eg) Jan B - Month, eg) January m - Month, 01-12 d - Day, 01-31 e - Day, 1-31 l - 12h Hour, 1-12 I - 12h Hour, 01-12 H - 24h Hour, 00-23 M - Minute, 00-59 S - Second, 00-60 p - AM or PM P - am or pm j - Day of the Year, 001-366
| Format | The format of the returned string. |
| FString FDateTime::ToHttpDate | ( | ) | const |
Returns the RFC 1123 string representation of the FDateTime.
The resulting string assumes that the FDateTime is in UTC.
| FString FDateTime::ToIso8601 | ( | ) | const |
Returns the ISO-8601 string representation of the FDateTime.
The resulting string assumes that the FDateTime is in UTC.
| FString FDateTime::ToString | ( | ) | const |
| FString FDateTime::ToString | ( | const TCHAR * | Format | ) | const |
Returns the string representation of this date.
ToString uses a non-standard format syntax (see below). If you need strftime-like syntax, then use ToFormattedString: a - am or pm A - AM or PM d - Day, 01-31 D - Day of the Year, 001-366 m - Month, 01-12 y - Year, YY Y - Year, YYYY h - 12h Hour, 01-12 H - 24h Hour, 00-23 M - Minute, 00-59 S - Second, 00-60 s - Millisecond, 000-999
| Format | The format of the returned string. |
| void FDateTime::ToString | ( | const TCHAR * | Format, |
| FStringBuilderBase & | Result | ||
| ) | const |
|
inline |
Returns this date as the number of seconds since the Unix Epoch (January 1st of 1970).
|
inline |
Returns this date as the number of seconds since the Unix Epoch (January 1st of 1970).
|
static |
Gets the UTC date and time on this computer.
This method returns the Coordinated Universal Time (UTC), which does not take the local computer's time zone and daylight savings settings into account. It should be used when comparing dates and times that should be independent of the user's locale. To get the date and time in the current locale, use Now() instead.
This method will use an estimate if USE_ESTIMATED_UTCNOW is 1. To calculate the estimate it will initialize a base reference time and keep track of the offset from that time with FPlatformTime::Cycles64().
This is appropriate for platforms whose implementations of FPlatformTime::UtcTime are expensive. To use, enable bUseEstimatedUtcNow in TargetRules. The rebase time is stored in time.EstimatedUtcNowRebaseTimeSeconds (default setting is 600 seconds).
|
static |
Validates the given components of a date and time value.
The allow ranges for the components are: Year: 1 - 9999 Month: 1 - 12 Day: 1 - DaysInMonth(Month) Hour: 0 - 23 Minute: 0 - 59 Second: 0 - 59 Millisecond: 0 - 999
Gets the hash for the specified date and time.
| DateTime | The date and time to get the hash for. |
Serializes the given date and time from or into the specified archive.
| Ar | The archive to serialize from or into. |
| DateTime | The date and time value to serialize. |
|
friend |
Serializes the given date and time from or into the specified structured archive slot.
| Slot | The structured archive slot to serialize from or into. |
| DateTime | The date and time value to serialize. |
|
staticprotected |
Holds the days per month in a non-leap year.
|
staticprotected |
Holds the cumulative days per month in a non-leap year.
|
staticprotected |
|
staticprotected |
|
staticprotected |
Holds the long and short day names.
|
staticprotected |
Holds the long and short month names.