datetime Module

Comprehensive datetime manipulation including extraction, construction, arithmetic, and formatting.

Extraction

Components

Epoch

Construction

Manipulation

Formatting

Function Reference

FunctionDescription
datetime::yearExtract the year from a datetime
datetime::monthExtract the month (1-12)
datetime::dayExtract the day of the month
datetime::hourExtract the hour (0-23)
datetime::minuteExtract the minute (0-59)
datetime::secondExtract the second (0-59)
datetime::nanosecondExtract the nanosecond component
datetime::day_of_yearGet the day of the year (1-366)
datetime::day_of_weekGet the day of the week (1=Monday, 7=Sunday)
datetime::quarterGet the quarter (1-4)
datetime::weekGet the ISO week number (1-53)
datetime::dateExtract the date component
datetime::timeExtract the time component
datetime::epochGet the Unix epoch timestamp in seconds
datetime::epoch_millisGet the Unix epoch timestamp in milliseconds
datetime::from_epochCreate a datetime from epoch seconds
datetime::from_epoch_millisCreate a datetime from epoch milliseconds
datetime::newCreate a new datetime from a date and time
datetime::nowGet the current datetime
datetime::addAdd a duration to a datetime
datetime::subtractSubtract a duration from a datetime
datetime::diffCalculate the difference between two datetimes
datetime::truncTruncate a datetime to a specified precision
datetime::ageCalculate the duration between two datetimes
datetime::formatFormat a datetime as a string