# How to obtain the date (or datetime) from local machine using pure Mojo?

**URL:** <https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051>\
**Category:** Mojo\
**Tags:** mojo-compiler\
**Created:** [July 31, 2025, 4:24am UTC](https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051 "2025-07-31T04:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EzRyder](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/ezryder/32/133_2.png) [@EzRyder](https://forum.modular.com/u/EzRyder)\
**Post date:** [July 31, 2025, 4:24am UTC](https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051/1 "2025-07-31T04:24:58Z")

</div>

What’s the standard way to obtain the `date` or `datetime` from the local machine using pure Mojo? I don’t see it from a quick search of the online docs, nor could kapa.ai provide a code example. Thanks!

---

<div class="post-metadata">

**Author:** ![rd4com](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@rd4com](https://forum.modular.com/u/rd4com)\
**Post date:** [July 31, 2025, 10:30am UTC](https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051/2 "2025-07-31T10:30:18Z")

</div>

Hi, turns out the date command is POSIX,  
so here is an quick way to get it:

```python
from subprocess import run
def main():
    var current = run(“date”)
    print(current)

```

The is also `external_call` to do it with an libc,

but i’m not familiar with theses structs, so there was my workaround 👍

---

<div class="post-metadata">

**Author:** ![EzRyder](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/ezryder/32/133_2.png) [@EzRyder](https://forum.modular.com/u/EzRyder)\
**Post date:** [July 31, 2025, 4:08pm UTC](https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051/3 "2025-07-31T16:08:41Z")

</div>

Excellent…that method works for me too! Thanks!!  
`from subprocess import run  
`dt_iso_8601 = run("date --iso-8601")``

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [August 7, 2025, 4:08pm UTC](https://forum.modular.com/t/how-to-obtain-the-date-or-datetime-from-local-machine-using-pure-mojo/2051/4 "2025-08-07T16:08:56Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
