Returns a formatted date/time string for a date (or the current date). Alias to the standard library function os.date.


See also Lua library functions.

Signature:

dateValue = date(["format" [, time]])

Arguments:

  • format - A string describing the formatting of time values (as in the ANSI C strftime()function), or *t to return the time as a table; optionally preceded by ! for Coordinated Universal Time instead of the local time zone; omitted for a date printed in the default format (string)
  • time - Time value to be formatted (see time() for description); if omitted, uses the current time (number)

Returns:

  • dateValue - A formatted date/time string, (string or table)

Examples:

date()
-- returns (e.g.) "Sun Jun 14 01:31:41 2009"
date("*t")
-- returns { hour=1, min=31, sec=41, wday=1, day=14, month=6, year=2009, yday=165, isdst=true }
This function is defined in the Lua standard libraries