# How to access the monotonic "steady" clock?

**URL:** https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078
**Category:** General Usage
**Tags:** time
**Created:** [January 22, 2025, 1:03pm UTC](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078 "2025-01-22T13:03:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)
#### Post date: [January 22, 2025, 1:03pm UTC](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078/1 "2025-01-22T13:03:35Z")

</div>

POSIX systems offer a “system clock”, represented as time since the UNIX epoch (1-1-1970), nowadays usually represented with a nanoseconds resolution. There’s also supposed to be a “monotonic clock”, also known as “steady\_clock” in the C++ chrono library, which is usually counting from the time the computer last booted, and it’s guaranteed to be monotonic. the `now()` and `time()` functions seem to return the system time always with the full date. Is there any Julia standard function to load the monotonic clock, or steady clock?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [January 22, 2025, 1:10pm UTC](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078/2 "2025-01-22T13:10:52Z")

</div>

[`time_ns()`](https://docs.julialang.org/en/v1/base/base/#Base.time_ns) uses [`uv_hrtime()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_hrtime), which is guaranteed to be monotonic (mod 2⁶⁴, so that time differences will increase monotonically as long as the system is running).

See also the discussion in [tic() should use monotonic clock · Issue #2464 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/2464) … I submitted a PR to clarify the documentation for `time_ns`: [clarify that time\_ns is monotonic by stevengj · Pull Request #57129 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/57129)

(`time_ns` almost surely uses the same underlying system call as `std::chrono::steady_clock`. e.g. it uses the POSIX `clock_gettime(CLOCK_MONOTONIC, &t)` function on Unix. This is _not_ “the calendar time since the UNIX epoch”, by the way … it’s usually related to time since the last reboot as you noted, though its behavior on system sleep is OS-dependent.)

---

<div class="post-metadata">

### Author: ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)
#### Post date: [January 23, 2025, 6:10pm UTC](https://discourse.julialang.org/t/how-to-access-the-monotonic-steady-clock/125078/4 "2025-01-23T18:10:31Z")

</div>

Perfect, thank you (again)! 🙂
