Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting from DateTime to string in Julia

Is there any user-friendly and efficient function to convert from a DateTime into a string? I'm thinking of something that would look like string(mydate, mydateformat), used for instance with mydate = Dates.now() and mydateformat = Dates.DateFormat("yyyy-mm-dd H:M:S").

like image 521
tiho Avatar asked Jul 15 '15 20:07

tiho


1 Answers

Thanks for asking this question; I realized I forgot to document the important Dates.format(dt::TimeType, df::DateFormat) function!

The usage is pretty much what you're looking for:

julia> dt = DateTime(2015,7,15,3,2)
2015-07-15T03:02:00

julia> Dates.format(dt, "yyyy-mm-dd HH:MM:SS")
"2015-07-15 03:02:00"
like image 152
quinnj Avatar answered Sep 26 '22 00:09

quinnj