API date

date is a reference to the os.date function. It is put in the global table as the os module is not available. date ([format [, time]])

It returns a string or a table containing the user's machine's current date and time (or the time represented by ), formatted according to the given string. If one wishes to supply your own format string, then it uses the same rules as strftime (Windows Mac). The special string  tells the   function to return a table.

This is a mirror of the Lua function os.date.

Note that the default format returned when calling the date function with no parameters will be different depending on whether the game is running on a Windows or a Macintosh computer. If you want your addon to be compatible with both systems, you should therefore not use date without parameters, instead, use

date("%m/%d/%y %H:%M:%S") to display the date in the default Windows format

-or-

date("%a %b %d %H:%M:%S %Y") to display the date in the default Macintosh format.

Be aware that if you use an incorrect format string, including any format specifiers not supported by the C library used in WoW, you will get the error message, "format too long". The error has nothing necessarily to do with the length of the format string; it is simply imprecise error wording in that version of Lua.

Compatibility
The Windows and Mac versions of strftime accept different format specifiers. Attempting to use one OS's exclusive specifiers on the other OS will throw the "format too long" error mentioned above.

There is, however, a common subset of specifiers that work on both Windows and Mac (those specified by the C89 standard). This subset consists of all of the Windows specifiers except %z and the # flag. The safest thing to do is refer to C89, or use a web-based tool like strftime.net.

Note that %z can be used on both OSes, but it will have a different meaning on each one (alias of %Z in Windows, time zone offset on Mac).