Skip to content
FutureBlitz

    Install

    Import std.time.timestamp

    std.time.timestamp

    Timestamps, points in time in UTC, to the nanosecond.

    Timestamp: a point in time, in UTC, to the nanosecond, from the year -999999999 to 999999999, as the real clock and Unix times give one. Its zero is 1970-01-01T00:00:00Z. A zone's clocks show it as a ZonedDateTime (in zone.fb). ToString and Parse write and read RFC 3339, ISO 8601's form for one, like "2026-10-23T12:30:00Z".

    std/time/timestamp.fb

    Types

    Timestamp struct

    Public Struct Timestamp Implements Comparable, Hashable, Printable, Defaultable

    A moment in time, as UTC counts it: its seconds since 1970-01-01T00:00:00Z, and the nanoseconds after them.

    Examples

    Local epoch = Timestamp.FromUnixSeconds(0)
    Expect(epoch == Timestamp.UnixEpoch())
    Expect("{epoch}" == "1970-01-01T00:00:00Z")
    Local day = epoch + 1.Days
    Expect(day.UnixSeconds == 86400)
    Expect(Timestamp.Parse("1970-01-02T00:00:00Z") == day)
    Expect(Timestamp.Parse("1970-01-02T02:00:00+02:00") == day)

    std/time/timestamp.fb, line 33

    • Public Static Method Now(): Timestamp static method #

      Now, on the real clock, which the OS can set back or on.

    • Public Static Method DefaultValue(): Timestamp static method #

      The Unix epoch, 1970-01-01T00:00:00Z.

    • Public Static Method UnixEpoch(): Timestamp static method #

      1970-01-01T00:00:00Z, where Unix time starts.

    • Public Static Method MinValue(): Timestamp static method #

      The earliest Timestamp there is.

    • Public Static Method MaxValue(): Timestamp static method #

      The latest Timestamp there is.

    • @PanicsAtCaller Public Static Method FromUnixSeconds(seconds: Int64, nanoseconds: Int64 = 0): Timestamp static method #

      The Timestamp that many seconds, and nanoseconds, after 1970-01-01T00:00:00Z, or before it below 0, as Unix time counts them, without leap seconds. One past the years a Timestamp holds panics.

    • Public Static Method FromUnixMilliseconds(milliseconds: Int64): Timestamp static method #

      The Timestamp that many milliseconds after 1970-01-01T00:00:00Z, or before it below 0.

    • Public Static Method FromUnixNanoseconds(nanoseconds: Int64): Timestamp static method #

      The Timestamp that many nanoseconds after 1970-01-01T00:00:00Z, or before it below 0.

    • Public Static Method Parse(text: String): Timestamp? static method #

      The Timestamp RFC 3339 writes, like "2026-10-23T12:30:00Z" or "2026-10-23T14:30:00.5+02:00", with "T", "t", or a space before the time, or Null.

    • @PanicsAtCaller Public Static Method Parse(text: String, pattern: String): Timestamp? static method #

      The Timestamp the text writes as the pattern says (see format.fb), or Null. A pattern without the date, or without an offset or a zone, panics.

    • Public Property UnixSeconds: Int64 property #

      Its seconds since 1970-01-01T00:00:00Z, rounded down, so a moment before it has the second before.

    • @PanicsAtCaller Public Property UnixMilliseconds: Int64 property #

      Its milliseconds since 1970-01-01T00:00:00Z, rounded down. Panics when they're past what an Int64 holds.

    • @PanicsAtCaller Public Property UnixNanoseconds: Int64 property #

      Its nanoseconds since 1970-01-01T00:00:00Z. Panics when they're past what an Int64 holds, as they are before 1677 or after 2262.

    • Public Property Nanosecond: Int property #

      Its nanoseconds past the second, from 0 to 999999999.

    • Public Method InZone(zone: TimeZone): ZonedDateTime method #

      It where the zone is.

    • Public Method ToUtc(): LocalDateTime method #

      Its date and time in UTC.

    • @PanicsAtCaller Operator +(a: Timestamp, b: Duration): Timestamp operator #

      b after a. One past the years a Timestamp holds panics.

    • @PanicsAtCaller Operator -(a: Timestamp, b: Duration): Timestamp operator #

      b before a. One past the years a Timestamp holds panics.

    • @PanicsAtCaller Operator -(a: Timestamp, b: Timestamp): Duration operator #

      How long it is from b to a, below 0 when a is earlier, which panics past the longest Duration, about 292 years.

    • Operator <(a: Timestamp, b: Timestamp): Bool operator #

      Whether a is before b.

    • Public Method ToString(): String method #

      As RFC 3339 writes it in UTC, with a fraction only when there is one, like "2026-10-23T12:30:00Z" and "2026-10-23T12:30:00.25Z".

    • Public Method ToRfc2822(): String method #

      As RFC 2822 writes it, in UTC: "Fri, 23 Oct 2026 12:30:00 +0000".

    • @PanicsAtCaller Public Method Format(pattern: String): String method #

      As the pattern says (see format.fb), in UTC.

    Report an issue with this page or with FutureBlitz on GitHub.