Donut Team is a labor of love, built and maintained by a small group of passionate developers. We invest our own time and resources to offer our tools, mods, and web services completely free of charge.

We don't run ads, and we will never sell your data - period.

If you've enjoyed anything we've created, please consider supporting our work with a one-time or monthly donation via our Ko-fi page . Every contribution helps us continue building great experiences for the community.

Dismiss
  • Modding Tools
  • Simpsons Hit & Run Multiplayer Server
  • Lua API Reference
  • DateTime Functions

DateTime.Date

Available since Version 1.0.

Returns a formatted date string based on the provided format string and the current date and time.

Syntax

DateTime.Date( format, [ epoch ] )

Arguments

  • format (string): A format string that specifies how the date should be formatted. It uses the .NET date and time format specifiers. For example, "yyyy-mm-dd HH:MM:SS" would format the date as "2021-01-01 12:34:56".
  • epoch (number, optional): An optional Unix timestamp (number of seconds since January 1, 1970) to format. If not provided, the current date and time will be used.

Return Values

(string): The formatted date string.

Examples

local formattedDate = DateTime.Date("yyyy-mm-dd HH:MM:SS")
print(formattedDate) -- Outputs: 2026-01-01 12:34:56 (example output, will vary based on current date and time)

local formattedDateFromEpoch = DateTime.Date("yyyy-mm-dd HH:MM:SS", 1609459200)
print(formattedDateFromEpoch) -- Outputs: 2021-01-01 00:00:00