C_DateAndTime.GetCurrentCalendarTime

From Warcraft Wiki
Jump to navigation Jump to search
GitHub Octocat.png  Townlong-Yak Globe.png  Townlong-Yak BAD.png  Blizz.gif  ProfIcons engineering.png C_DateAndTime.GetCurrentCalendarTime 11.1.5 (60428)4.4.2 (59734)1.15.7 (60191) + 8.1.0 / 2.5.1 / 1.14.0
GitHub Octocat.png  Townlong-Yak Globe.png C_Calendar.GetDate + 8.0.1
GitHub Octocat.png  Townlong-Yak Globe.png  Wowprogramming.png CalendarGetDate + 3.0.2

Returns the realm's current date and time.

currentCalendarTime = C_DateAndTime.GetCurrentCalendarTime()

Returns

currentCalendarTime
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.GetCurrentCalendarTime()
local weekDay = CALENDAR_WEEKDAY_NAMES[d.weekday]
local month = CALENDAR_FULLDATE_MONTH_NAMES[d.month]
print(format("The time is %02d:%02d, %s, %d %s %d", d.hour, d.minute, weekDay, d.monthDay, month, d.year))
-- The time is 07:55, Friday, 15 March 2019

Comparison

When in a EU time zone CEST (UTC+2) and playing on Moon Guard US, CDT (UTC-5). The examples were taken at the same time. Note that time() and date() are tied to your system's clock which can be manually changed.

-- unix time
time()                                 -- 1596157547
GetServerTime()                        -- 1596157549

-- local time, same as `date(nil, time())`
date()                                 -- "Fri Jul 31 03:05:47 2020"

-- realm time
GetGameTime()                          -- 20, 4
C_DateAndTime.GetCurrentCalendarTime() -- hour:20, minute:4
C_DateAndTime.GetServerTimeLocal()     -- 1596139440 unix time offset by the server's time zone (e.g. UTC minus 5 hours)

Patch changes