Date and time
See this page for a general introduction to date and time handling in Numbat.
Defined in: datetime::functions, datetime::human
now
Returns the current date and time.
datetime
Parses a string (date and time) into a DateTime object. See here for an overview of the supported formats.
Example
datetime("2022-07-20 21:52 Europe/Berlin")
= 2022-07-20 21:52:00 CEST (UTC +02), Europe/Berlin [DateTime]
Example
Run this exampleformat_datetime
Formats a DateTime object as a string.
Example
format_datetime("This is a date in %B in the year %Y.", datetime("2022-07-20 21:52 +0200"))
= "This is a date in July in the year 2022." [String]
get_local_timezone
Returns the users local timezone.
tz
Returns a timezone conversion function, typically used with the conversion operator.
Example
datetime("2022-07-20 21:52 +0200") -> tz("Europe/Amsterdam")
= 2022-07-20 21:52:00 CEST (UTC +02), Europe/Amsterdam [DateTime]
Example
datetime("2022-07-20 21:52 +0200") -> tz("Asia/Taipei")
= 2022-07-21 03:52:00 CST (UTC +08), Asia/Taipei [DateTime]
unixtime
Converts a DateTime to a UNIX timestamp. Can be used on the right hand side of a conversion operator: now() -> unixtime.
from_unixtime
Converts a UNIX timestamp to a DateTime object.
today
Returns the current date at midnight (in the local time).
date
Parses a string (only date) into a DateTime object.
time
Parses a string (time only) into a DateTime object.
calendar_add
Adds the given time span to a DateTime. This uses leap-year and DST-aware calendar arithmetic with variable-length days, months, and years.
Example
calendar_add(datetime("2022-07-20 21:52 +0200"), 2 years)
= 2024-07-20 21:52:00 (UTC +02) [DateTime]
calendar_sub
Subtract the given time span from a DateTime. This uses leap-year and DST-aware calendar arithmetic with variable-length days, months, and years.
Example
calendar_sub(datetime("2022-07-20 21:52 +0200"), 3 years)
= 2019-07-20 21:52:00 (UTC +02) [DateTime]
weekday
Get the day of the week from a given DateTime.
julian_date (Julian date)
Convert a DateTime to a Julian date, the number of days since the origin of the Julian date system (noon on November 24, 4714 BC in the proleptic Gregorian calendar).
More information here.
human (Human-readable time duration)
Converts a time duration to a human-readable string in days, hours, minutes and seconds. More information here.
How long is a microcentury?
Run this example