# What’s the correct way to convert \`Dates.unix2datetime(mtime(fpath))\` to a datetim

**URL:** <https://discourse.julialang.org/t/what-s-the-correct-way-to-convert-dates-unix2datetime-mtime-fpath-to-a-datetim/54353>\
**Category:** General Usage\
**Created:** [February 1, 2021, 1:46am UTC](https://discourse.julialang.org/t/what-s-the-correct-way-to-convert-dates-unix2datetime-mtime-fpath-to-a-datetim/54353 "2021-02-01T01:46:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [February 1, 2021, 1:46am UTC](https://discourse.julialang.org/t/what-s-the-correct-way-to-convert-dates-unix2datetime-mtime-fpath-to-a-datetim/54353/1 "2021-02-01T01:46:27Z")

</div>

What’s the correct way to convert `Dates.unix2datetime(mtime(fpath))` to a datetime with the correct time zone for my system? I get a time 5 hours in the future, so I assume it’s returning UTC.

```julia

julia&gt; Dates.unix2datetime(mtime(fpath))
2021-01-31T22:46:14.370

julia&gt; Dates.now()
2021-01-31T17:46:23.646

```

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1612133207300700?thread_ts=1612133207.300700&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [February 1, 2021, 1:50am UTC](https://discourse.julialang.org/t/what-s-the-correct-way-to-convert-dates-unix2datetime-mtime-fpath-to-a-datetim/54353/2 "2021-02-01T01:50:19Z")

</div>

Posting the answer from the slack discussion.

For this particular case, there was a requirement to only use functions in `Base` (which doesn’t include the `Dates` stdlib, or the `TimeZones` package)

Using functions only in `Base`:

```julia
julia> Base.Libc.strftime("%FT%R%Z", mtime(fpath))
"2021-02-01T01:15CET"
julia> Base.Libc.strftime("%FT%R%z", mtime(fpath))
"2021-02-01T01:15+0100"

```
