# Higher resolution DateTime/TimeStamp

**URL:** <https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069>\
**Category:** Internals & Design\
**Tags:** dates\
**Created:** [April 5, 2017, 3:54pm UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069 "2017-04-05T15:54:57Z")\
**Posts on this page:** 5\
**Page:** 3

<div class="post-metadata">

**Author:** ![jackf](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jackf](https://discourse.julialang.org/u/jackf)\
**Post date:** [February 2, 2019, 4:00pm UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069/42 "2019-02-02T16:00:32Z")

</div>

Thanks - that is indeed a problem I hadn’t thought of…

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 2, 2019, 4:14pm UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069/43 "2019-02-02T16:14:35Z")

</div>

It may be better to abstract the functionality to an interface, for which the user can define conforming implementations. I experimented with the opposite problem (saving bits by changing the epoch) in

[https://github.com/tpapp/FlexDates.jl](https://github.com/tpapp/FlexDates.jl)

and it would be nice to have all these approaches work together.

---

<div class="post-metadata">

**Author:** ![helgee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgee/32/2022_2.png) [@helgee](https://discourse.julialang.org/u/helgee)\
**Post date:** [February 6, 2019, 8:46am UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069/44 "2019-02-06T08:46:07Z")

</div>

For the record:

I have published the first version of [AstroTime.jl](https://discourse.julialang.org/t/ann-astrotime-jl-astronomical-time-keeping-in-julia/20496).

We had a discussion about the accuracy and resolution here: [https://github.com/JuliaAstro/AstroTime.jl/issues/28](https://github.com/JuliaAstro/AstroTime.jl/issues/28)

In theory we should be able to achieve an accuracy of 55 attoseconds for a range of 10x the age of the universe (I have not tested these extremes though because most date-based algorithms become meaningless there). Shifting an epoch with a subsecond offset close to machine precision by a million years works though (see [here](https://github.com/JuliaAstro/AstroTime.jl/blob/master/test/epochs.jl#L2)) 😄

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [February 6, 2019, 10:00am UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069/45 "2019-02-06T10:00:17Z")

</div>

> [@helgee](#):
>
> Shifting an epoch with a subsecond offset close to machine precision by a million years works though

![angtft](https://global.discourse-cdn.com/julialang/original/3X/1/3/1358b840e1ec24f6218df917b28671020229f50f.jpeg)

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [February 13, 2019, 9:19am UTC](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069/46 "2019-02-13T09:19:05Z")

</div>

`pkg> add TimesDates`

```julia
using TimesDates, Dates

tm = TimeDate(now()) + Microsecond(12) + Nanosecond(345)
2019-02-13T04:15:48.250012345

string(tm)
"2019-02-13T04:15:48.250012345"

```

q.v. [GitHub - JeffreySarnoff/TimesDates.jl: Nanosecond resolution for Time and Date, TimeZones](https://github.com/JeffreySarnoff/TimesDates.jl)

[Previous page](https://discourse.julialang.org/t/higher-resolution-datetime-timestamp/3069.md?page=2)
