mktime
datetimeCreates a timestamp from date and time components
Syntax
mktime(year, month, day, hour?, min?, sec?) Parameters
year (number) The year (e.g., 2024)
month (number) The month (1-12)
day (number) The day of the month (1-31)
hour (number) optional The hour (0-23)
min (number) optional The minute (0-59)
sec (number) optional The second (0-59)
Returns
timestamp A timestamp constructed from the provided components
Examples
Create a date without time
Input:
mktime(2024, 1, 15) Output:
"2024-01-15" Create a full timestamp
Input:
mktime(2024, 1, 15, 14, 30, 0) Output:
"2024-01-15 14:30:00" Build timestamps from data
Input:
map({start: mktime(.year, .month, .day)}) Output:
Construct dates from component fields The mktime() function constructs a timestamp from individual date and time components. Time components (hour, minute, second) are optional.
Usage
Use mktime() to build timestamps from separate date components, reconstruct dates from parsed data, or create specific test dates.