API GetGameTime
From WoWWiki
Returns the current server time in hours and minutes
hours,minutes = GetGameTime();
Parameters
Returns
- hours
- Number - The current hour (0-23).
- minutes
- Number - The minutes passed in the current hour (0-59).
Example
local hour,minute = GetGameTime(); message(hour .. ":" .. minute);
Result
A message with the current server time appears.
To use this in a macro:
/script local hour,minute = GetGameTime();DEFAULT_CHAT_FRAME:AddMessage (hour .. ":" .. minute);
Note: This function appears to return the time using the time zone of the physical server you are currently on, which may not be the same as the login world server for your character. If you login to the world server Ysera, for example, the time returned will be of the time zone of that server, which for Ysera currently is Eastern. But if you enter a pvp instance, or any instance, the timezone of the server for that instance may be different, such as Pacific, in which case the time returned may suddenly jump hours ahead or back. Please keep this in mind if using this time for anything important functionally, such as diffing times or using as part of functional historical data.
