Stream: helpdesk (published)

Topic: ✔ printing `Dates.today()`in specific format


view this post on Zulip Leandro Martínez (Jul 01 2023 at 00:14):

How can I print the output of Dates.today() in the following format: 30-Jun-23?

view this post on Zulip Leandro Martínez (Jul 01 2023 at 00:16):

I'm confused by the docs, dateformat appears to parse a string, but not the other way around (convert a Date object to a string with specific format)

view this post on Zulip Daniel VandenHeuvel (Jul 01 2023 at 00:24):

julia> current_date = Dates.today()
2023-07-01

julia> formatted_date = Dates.format(current_date, "d-U-yy")
"1-July-23"

This seems to do it

view this post on Zulip Leandro Martínez (Jul 01 2023 at 00:29):

Great, thanks. It is there in the docs, but only in the list of functions, in the examples it is not mentioned, so I didn't see it.

This is exactly what I wanted:

julia> today = Dates.today()
2023-06-30

julia> Dates.format(today, "dd-u-yy")
"30-Jun-23"

view this post on Zulip Notification Bot (Jul 01 2023 at 00:29):

Leandro Martínez has marked this topic as resolved.


Last updated: Dec 28 2024 at 04:38 UTC