# std.time.Timer got removed, what are the plans for it if any?

**URL:** <https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349>\
**Category:** Explain\
**Tags:** standard-library\
**Created:** [February 16, 2026, 1:26pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349 "2026-02-16T13:26:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![miagi](https://ziggit.dev/user_avatar/ziggit.dev/miagi/32/6745_2.png) [@miagi](https://ziggit.dev/u/miagi)\
**Post date:** [February 16, 2026, 1:26pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/1 "2026-02-16T13:26:13Z")

</div>

I was using it one of my projects, and just noticed it’s gone. I tried searching about it but was not able to find much so I’m asking here.

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [February 16, 2026, 2:01pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/2 "2026-02-16T14:01:54Z")

</div>

It’s trivial to implement, I don’t see why it existed in the first place.

zigs time API is getting an overhaul with Io, you now have more control over what clock to use. Even with the removal of `Timer` I would say the API has generally more convenience.

You’ll find every thing, except the unit conversion amounts, under `std.Io` now. Perhaps that will change in the future IDK.

---

<div class="post-metadata">

**Author:** ![miagi](https://ziggit.dev/user_avatar/ziggit.dev/miagi/32/6745_2.png) [@miagi](https://ziggit.dev/u/miagi)\
**Post date:** [February 16, 2026, 2:21pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/3 "2026-02-16T14:21:36Z")

</div>

Yes, everything that I need is under `Timestamp` now and having a clock to choose from , I like.

---

<div class="post-metadata">

**Author:** ![PauSolerValades](https://ziggit.dev/user_avatar/ziggit.dev/pausolervalades/32/7429_2.png) [@PauSolerValades](https://ziggit.dev/u/PauSolerValades)\
**Post date:** [February 16, 2026, 3:30pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/4 "2026-02-16T15:30:16Z")

</div>

I’ve asked a very similar question to this [here](https://ziggit.dev/t/what-happened-to-timestamp-and-what-actually-is-clock/14310)!

I ended up doing this to count the time :))

```zig
const start = Io.Clock.real.now(init.io);
_ = doSomeWork();
const end = Io.Clock.real.now(init.io);

const duration = std.Io.Timestamp.durationTo(start, end); 
try stdout.print("Time Elapsed: {d} ms\n", .{duration.toMilliseconds()});

```

I find annoying that there isn’t (or I have not seen ofc) a function in Timestamp to return the seconds as a float (eg, 3.334 s) but it can be easily done!

---

<div class="post-metadata">

**Author:** ![miagi](https://ziggit.dev/user_avatar/ziggit.dev/miagi/32/6745_2.png) [@miagi](https://ziggit.dev/u/miagi)\
**Post date:** [February 16, 2026, 6:20pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/5 "2026-02-16T18:20:18Z")

</div>

You can use conversion from `std.time`. I’ll show larger snippets so you can have more context.  
Getting initial timestamp:

```zig
    // Timer for switching logic and syncing threads. If time exceeds duration (specified in sec), switch endpoints.
    // Block switcihing on every packet sent from server to client
    var timer: ?std.Io.Clock.Timestamp = null;
    const time: ?usize = config.switcher.timer;
    var switcher_thread: ?std.Thread = null;
    var packet_arrived = true;

    // Comply with the switcher flag
    if (config.switcher.enabled) if (time) |seconds| {
        std.log.info("Spawning switcher thread....", .{});
        timer = std.Io.Clock.Timestamp.now(io, .awake);
        switcher_thread = try std.Thread.spawn(.{}, switcher, .{
            io,
            seconds,
            &timer,
            servers,
            &current_id,
            &packet_arrived,
        });
    } else {
        std.log.debug("Switcher enabled but timer interval value is: {any}", .{time});
        return error.FailedToUnwrap;
    } else {
        std.log.info("Switching disabled, using endpoint derived form ID....", .{});
    }

```

And my switcher thread where I do a reset and duration check:

```zig
fn switcher(
    io: std.Io,
    seconds: usize,
    timer: *?std.Io.Clock.Timestamp,
    servers: []std.Io.net.IpAddress,
    current_id: *usize,
    packet_arrived: *bool,
) !void {
    // Unwrap timer optional
    if (timer.*) |*t| {
        // Declare constants once before the main loop
        const duration: u64 = std.time.ns_per_s * seconds;

        while (true) {
            const elapsed = t.untilNow(io).raw.nanoseconds;
            std.log.debug("Timer time elapsed: {d}", .{elapsed});
            std.log.debug("Timer time duration: {d}", .{duration});
            std.log.debug("Timer packet_arrived state: {}", .{packet_arrived.*});

            // Main check is if packet has arrived
            if (!packet_arrived.*) {
                // Second check is if enough time has passsed before switching
                if (elapsed < duration) {
                    try io.sleep(.fromNanoseconds(duration - elapsed), .awake);
                    continue;
                }
                const new_id = (current_id.* + 1) % servers.len;
                current_id.* = new_id;
                std.log.info("Switched servers endpoints!", .{});
                std.log.info("Current endpoint: {f}", .{&servers[current_id.*]});
                // Reset packet state
                packet_arrived.* = true;
            }
            // Reset timer to sync threads
            t.* = std.Io.Clock.Timestamp.now(io, .awake);
            try io.sleep(.fromNanoseconds(duration), .awake);
        }
    } else {
        std.log.err("Switcher got called but timer variable value is: {any}", .{timer});
        return error.FailedToUnwrap;
    }
}

```

In case you want to see more code, it’s from this tool I wrote:

> **[GitHub - jovmarkovic/wg-forwarder at 0.16](https://github.com/jovmarkovic/wg-forwarder/tree/0.16)**
>
> 0.16

For some reason I still hesitate to make an official showcase for it 😃

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [February 16, 2026, 7:42pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/6 "2026-02-16T19:42:05Z")

</div>

> [@PauSolerValades](#):
>
> `const duration = std.Io.Timestamp.durationTo(start, end);`

FWIW you can rewrite this to:

```zig
const duration = start.durationTo(end);

```

…in my own code, I use this for elapsed time (where Timestamp has been imported as `const Timestamp = std.Io.Timestamp;`:

```zig
const startTime = Timestamp.now(io, .real);
// ...
const elapsedTime = startTime.untilNow(io, .real);

```

---

<div class="post-metadata">

**Author:** ![darnellbrawner](https://ziggit.dev/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@darnellbrawner](https://ziggit.dev/u/darnellbrawner)\
**Post date:** [March 4, 2026, 1:41am UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/7 "2026-03-04T01:41:37Z")

</div>

RIP Timer 🥲 . I thought it was a nice quick to understand bundle of functionality. Sad to see it go.

---

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [March 4, 2026, 7:01am UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/8 "2026-03-04T07:01:40Z")

</div>

I recently replaced time.Timer in zbench ( [GitHub - hendriknielaender/zBench: 📊 zig benchmark · GitHub](https://github.com/hendriknielaender/zBench) ), the new “timer” is basically just

```zig
const t0 = Timestamp.now(io, .awake);
// do stuff synchronously
const t1_ns = t0.untilNow(io, .awake).toNanoseconds(); 

```

This appears plain and simple, no unnecessary abstraction. Even better, the new variant lets me choose a clock. Great work @ zig-contributors! And @floooh for highlighting this functionality here.

---

<div class="post-metadata">

**Author:** ![miagi](https://ziggit.dev/user_avatar/ziggit.dev/miagi/32/6745_2.png) [@miagi](https://ziggit.dev/u/miagi)\
**Post date:** [March 4, 2026, 7:28am UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/9 "2026-03-04T07:28:34Z")

</div>

I was wondering how you `toNanoseconds()` function, and the difference is that I was using `std.Io.Clock.Timestamp` and you were using `std.Io.Timestamp`.

---

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [March 4, 2026, 11:31am UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/10 "2026-03-04T11:31:35Z")

</div>

Yes, this is a bit confusing, that there are two kind of `Timestamp`s. You should be able to use `std.Io.Clock.Timestamp.raw` to get the `std.Io.Timestamp` though.

---

<div class="post-metadata">

**Author:** ![dee0xeed](https://ziggit.dev/letter_avatar_proxy/v4/letter/d/3ab097/32.png) [@dee0xeed](https://ziggit.dev/u/dee0xeed)\
**Post date:** [March 7, 2026, 9:24pm UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/11 "2026-03-07T21:24:30Z")

</div>

just use event-driven-state-machines, like this

> <https://github.com/dee0xeed/edsm-in-zig-demo-2/blob/main/src/common-sm/rx.zig#L142>

---

<div class="post-metadata">

**Author:** ![miagi](https://ziggit.dev/user_avatar/ziggit.dev/miagi/32/6745_2.png) [@miagi](https://ziggit.dev/u/miagi)\
**Post date:** [March 10, 2026, 8:28am UTC](https://ziggit.dev/t/std-time-timer-got-removed-what-are-the-plans-for-it-if-any/14349/12 "2026-03-10T08:28:00Z")

</div>

If this was a reply to one of my messages, would you care to explain what you meant by this? If it was a reply to one of my messages, I have a hard time following the flow to see how it is beneficial to my use case.  
I have two UDP ports on different threads, switcher on the third that wakes up in specific intervals, checks if enough time had passed since the last arrived package, if it was, check the packet\_arrived state else go back to sleep for the remainder of the time left
