# How to put a timestamp in a filename on Windows?

**URL:** <https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155>\
**Category:** General Usage\
**Created:** [March 29, 2021, 9:07am UTC](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155 "2021-03-29T09:07:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivier\_Merchiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivier_merchiers/32/4073_2.png) [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Post date:** [March 29, 2021, 9:07am UTC](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155/1 "2021-03-29T09:07:40Z")

</div>

Hello everyone,

On linux I do this very common thing of putting a timestamp in the filenames that are produced by my simulations:

```julia
a=1.0
b=1.5 
using Dates
filename =string(now())*"_parameter1=$(a)_parameter2=$(b).txt"
"2021-03-29T11:02:33.672_parameter1=1.0_parameter2=1.5.txt"

```

No problem in Linux to save a file with such a name, but on windows, this fails since windows does not accept filenames with colons.

How do people get around that issue?  
I tried to reformat the timestamp, form `2021-03-29T11:02:33.672` to `2021-03-29T11-02-33.672`

But I could not find the way how to do that using Dates.  
Any pointers would be very much appreciated.

Thanks,  
Olivier

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 29, 2021, 9:40am UTC](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155/2 "2021-03-29T09:40:04Z")

</div>

You can use e.g. something like

```julia
Dates.format(now(),"yyyymmdd")

```

of course using your own formatting wishes.  
You can find the format characters here: [Dates · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.format-Tuple%7BTimeType,%20AbstractString%7D)

---

<div class="post-metadata">

**Author:** ![Olivier\_Merchiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivier_merchiers/32/4073_2.png) [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Post date:** [March 29, 2021, 9:47am UTC](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155/3 "2021-03-29T09:47:23Z")

</div>

Thanks a lot!

Olivier
