WoW:API date: Difference between revisions

516 bytes added ,  15 August 2023
m
Move page script moved page API date to WoW:API date without leaving a redirect
No edit summary
m (Move page script moved page API date to WoW:API date without leaving a redirect)
 
(10 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<tt>date ([format [, time]])</tt>
{{wowlua}}
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 <tt>time</tt>), formatted according to the given string <tt>format</tt>.  If one wishes to supply your own format string, then it uses the same rules as [http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html strftime()].  The special string <tt>*t</tt> tells the <tt>date()</tt> function to return a table.


This is a mirror of the LUA function [http://www.lua.org/manual/5.0/manual.html#5.7 os.date()].
It returns a string or a table containing the user's machine's current date and time (or the [[API_time|time]] represented by <tt>time</tt>), formatted according to the given string <tt>format</tt>. If one wishes to supply your own format string, then it uses the same rules as [http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html strftime()]. The special string <tt>
*t</tt> tells the <tt>date()</tt> function to return a table.


If one supplies no arguments, it returns the current date and time formatted using the following string: <tt>%m/%d/%y %H:%M:%S</tt>
This is a mirror of the LUA function [http://www.lua.org/manual/5.1/manual.html#pdf-os.date 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 PC 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 PC format
 
-or-
 
date("%a %b %d %H:%M:%S %Y")
to display the date in the default Macintosh format
 
== Also see ==
* {{api|GetGameTime}}()
Anonymous user