Skip to main content
Time and date operations backed by chrono.
import date

Functions

FunctionDescriptionExampleResult
date.now()Current time (HH:MM:SS)date.now()"14:30:05"
date.today()Current date (YYYY-MM-DD)date.today()"2026-02-16"
date.timestamp()Unix timestamp (seconds)date.timestamp()1739712605
date.timestamp_ms()Unix timestamp (milliseconds)date.timestamp_ms()1739712605000
date.format(fmt)Format current timedate.format("%H:%M")"14:30"
date.parse(str, fmt)Parse date stringdate.parse("2026-01-01", "%Y-%m-%d")date value
date.year()Current yeardate.year()2026
date.month()Current month (1–12)date.month()2
date.day()Current day (1–31)date.day()16
date.weekday()Day of the weekdate.weekday()"Monday"
date.sleep(ms)Sleep for millisecondsdate.sleep(1000)

Format Strings

Based on C strftime.
CodeMeaningExample
%Y4-digit year2026
%mMonth (01–12)02
%dDay (01–31)16
%HHour (00–23)14
%MMinute (00–59)30
%SSecond (00–59)05
%AFull weekdayMonday
%BFull month nameFebruary

Examples

import date

print("Today: {date.today()}")
print("Time: {date.now()}")
print("Day: {date.weekday()}")

# Custom format
formatted = date.format("%B %d, %Y at %H:%M")
print(formatted)
# Output: February 16, 2026 at 14:30

Compile Flag

cargo build --release --no-default-features --features mod_date