Skip to main content

DateTime.parse()

Create a DateTime by parsing a date string.

Signature​

DateTime.parse(dateString: string): DateTime

Parameters​

ParameterTypeDescription
dateStringstringDate text, for example 2026-10-25 09:30:00

Returns

DateTime - The parsed date.

Description​

Accepts the same formats as DateTime(dateString). An invalid string throws an error, so wrap it in pcall() when the text comes from a user or the network.

Example​

local date = DateTime.parse("2026-10-25 09:30:00")
toast(date:format("dd MMM yyyy"))

Compatible Version: 1.0.0.31 and up