Skip to content

Date

Date construction and accessors. Floe has no new keyword, so the Date module bridges the gap for creating JS Date objects and reading their fields.

FunctionSignatureDescription
Date.now() -> DateCurrent date and time
Date.fromstring -> DateParse a date string
Date.fromMillisnumber -> DateCreate from Unix milliseconds
Date.yearDate -> numberFull year (e.g. 2024)
Date.monthDate -> numberMonth (1-12, 1-indexed!)
Date.dayDate -> numberDay of month (1-31)
Date.hourDate -> numberHour (0-23)
Date.minuteDate -> numberMinute (0-59)
Date.secondDate -> numberSecond (0-59)
Date.millisDate -> numberUnix timestamp in milliseconds
Date.toIsoDate -> stringISO 8601 string
// Create dates
const now = Date.now()
const release = Date.from("2024-06-15")
const epoch = Date.fromMillis(0)
// Read fields with pipes
const year = release |> Date.year // 2024
const month = release |> Date.month // 6 (1-indexed, not 0!)
const day = release |> Date.day // 15
// Convert to string or timestamp
const iso = now |> Date.toIso // "2024-..."
const timestamp = now |> Date.millis // 1718...

Date.month returns 1-12 (January = 1), unlike JavaScript’s getMonth() which returns 0-11. This fixes a common JS footgun.

For date arithmetic, formatting, and timezone handling, use npm libraries like date-fns via interop — the stdlib only covers construction and basic access.