# Get creation date from a file function missing?

**URL:** <https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487>\
**Category:** Questions & Answers\
**Tags:** racket, filesystem\
**Created:** [December 29, 2021, 4:11am UTC](https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487 "2021-12-29T04:11:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurinoku](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@kurinoku](https://racket.discourse.group/u/kurinoku)\
**Post date:** [December 29, 2021, 4:11am UTC](https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487/1 "2021-12-29T04:11:05Z")

</div>

The procedure [`file-or-directory-modify-seconds`](https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._file-or-directory-modify-seconds%29%29) exists, yet I can't seem to find a similar function for the creation date.

---

<div class="post-metadata">

**Author:** ![sschwarzer](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/sschwarzer/32/1940_2.png) [@sschwarzer](https://racket.discourse.group/u/sschwarzer)\
**Post date:** [December 29, 2021, 12:04pm UTC](https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487/2 "2021-12-29T12:04:38Z")

</div>

[Snapshot releases](https://plt.cs.northwestern.edu/snapshots/) have a function [`file-or-directory-stat`](https://www.cs.utah.edu/plt/snapshots/current/doc/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._file-or-directory-stat%29%29), where the result hash contains the fields `'creation-time-seconds` and `'creation-time-nanoseconds`.

However, there are a few caveats:

- On both Posix and Windows, the underlying C stat call returns a struct with a "ctime" field. On Windows, this is the creation time, but on Posix, this is the status change time. So the creation timestamp is only available on Windows.
- In favor of a simpler implementation, there's (at least currently) no result more accurate than seconds, i.e. the `'creation-time-nanoseconds` hash value is the same hash value as for `'creation-time-seconds`, but multiplied by 1e9.

What do you need the creation time for?

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [December 29, 2021, 5:38pm UTC](https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487/3 "2021-12-29T17:38:59Z")

</div>

> [@sschwarzer](#):
>
> On both Posix and Windows, the underlying C stat call returns a struct with a "ctime" field. On Windows, this is the creation time, but on Posix, this is the status change time. So the creation timestamp is only available on Windows.

Seems like this should be more explicitly documented!

---

<div class="post-metadata">

**Author:** ![sschwarzer](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/sschwarzer/32/1940_2.png) [@sschwarzer](https://racket.discourse.group/u/sschwarzer)\
**Post date:** [December 29, 2021, 10:50pm UTC](https://racket.discourse.group/t/get-creation-date-from-a-file-function-missing/487/4 "2021-12-29T22:50:37Z")

</div>

> [@joeld](#):
>
> Seems like this should be more explicitly documented!

I think you're right. I thought I had documented this, but looking at the snapshot documentation, apparently I didn't. I'll make a PR (if I don't forget it 😉 ).

Edit: [Done](https://github.com/racket/racket/pull/4115), but I described the matter only from the perspective of a Racket user, without going into the details of the underlying `stat` calls on Posix and Windows.
