C_DateAndTime.GetCalendarTimeFromEpoch

From Warcraft Wiki
Jump to navigation Jump to search

Returns the date for a specified amount of time since the UNIX epoch for the OS time zone.

date = C_DateAndTime.GetCalendarTimeFromEpoch(epoch)

Arguments

epoch
number - time in microseconds

Returns

date
CalendarTime
Field Type Description
year number The current year (e.g. 2019)
month number The current month [1-12]
monthDay number The current day of the month [1-31]
weekday number The current day of the week (1=Sunday, 2=Monday, ..., 7=Saturday)
hour number The current time in hours [0-23]
minute number The current time in minutes [0-59]

Example

local d = C_DateAndTime.GetCalendarTimeFromEpoch(1e6 * 60 * 60 * 24)
print(format("One day since epoch is %d-%02d-%02d %02d:%02d", d.year, d.month, d.monthDay, d.hour, d.minute))
> One day since epoch is 1970-01-02 01:00

Patch changes

Battle for Azeroth Patch 8.1.0 (2018-12-11): Moved to C_DateAndTime.GetCalendarTimeFromEpoch(), the previous alias is deprecated. [1]
Battle for Azeroth Patch 8.0.1 (2018-07-17): Added as C_DateAndTime.GetDateFromEpoch()