datetime Module
Comprehensive datetime manipulation including extraction, construction, arithmetic, and formatting.
Extraction
datetime::year
Extract the year from a datetime
datetime::month
Extract the month (1-12)
datetime::day
Extract the day of the month
datetime::hour
Extract the hour (0-23)
datetime::minute
Extract the minute (0-59)
datetime::second
Extract the second (0-59)
datetime::nanosecond
Extract the nanosecond component
datetime::day_of_year
Get the day of the year (1-366)
datetime::day_of_week
Get the day of the week (1=Monday, 7=Sunday)
datetime::quarter
Get the quarter (1-4)
datetime::week
Get the ISO week number (1-53)
Components
Epoch
Construction
Manipulation
Formatting
Function Reference
| Function | Description |
|---|---|
| datetime::year | Extract the year from a datetime |
| datetime::month | Extract the month (1-12) |
| datetime::day | Extract the day of the month |
| datetime::hour | Extract the hour (0-23) |
| datetime::minute | Extract the minute (0-59) |
| datetime::second | Extract the second (0-59) |
| datetime::nanosecond | Extract the nanosecond component |
| datetime::day_of_year | Get the day of the year (1-366) |
| datetime::day_of_week | Get the day of the week (1=Monday, 7=Sunday) |
| datetime::quarter | Get the quarter (1-4) |
| datetime::week | Get the ISO week number (1-53) |
| datetime::date | Extract the date component |
| datetime::time | Extract the time component |
| datetime::epoch | Get the Unix epoch timestamp in seconds |
| datetime::epoch_millis | Get the Unix epoch timestamp in milliseconds |
| datetime::from_epoch | Create a datetime from epoch seconds |
| datetime::from_epoch_millis | Create a datetime from epoch milliseconds |
| datetime::new | Create a new datetime from a date and time |
| datetime::now | Get the current datetime |
| datetime::add | Add a duration to a datetime |
| datetime::subtract | Subtract a duration from a datetime |
| datetime::diff | Calculate the difference between two datetimes |
| datetime::trunc | Truncate a datetime to a specified precision |
| datetime::age | Calculate the duration between two datetimes |
| datetime::format | Format a datetime as a string |
