Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print current time in Julia

Tags:

julia

Is there an elegant way of printing the current time in Julia?

println("$(Dates.hour(now())):$(Dates.minute(now()))")

would inelegantly and incorrectly print 12.01pm as 12:1.

like image 344
u003f Avatar asked May 16 '16 12:05

u003f


People also ask

What is Julia date?

As Julia Date and DateTime values are represented according to the ISO 8601 standard, 0000-01-01T00:00:00 was chosen as base (or "rounding epoch") from which to begin the count of days (and milliseconds) used in rounding calculations.

What day of the week is Julia on?

After March 31, only one new episode of Julia premieres every Thursday. That takes the show through May 5 with the season finale. Over the course of the series, viewers will also see how culinary television was born.


1 Answers

You could use Dates.format to format your date/times (check here for formating instructions). For your given example:

>>> Dates.format(now(), "HH:MM")  
"13:18"

>>> typeof(ans)
ASCIIString

The return of Dates.format is a string itself (which is instantly printed in a REPL or you can print it with any printing function).

like image 122
Imanol Luengo Avatar answered Oct 14 '22 06:10

Imanol Luengo