To get the basic time information, you can use the time()
function that returns, for example, 1.408719961424e9
, the number of seconds since a predefined date called the epoch (normally, the 1st of January 1970 on Unix system), This is useful for measuring the time interval between two events, for example, to benchmark how long a long calculation takes:
start_time = time() # long computation time_elapsed = time() - start_time println("Time elapsed: $time_elapsed")
Most useful function is strftime(time())
that returns a string in "22/08/2014 17:06:13"
format.
If you want more functionality greater than equal to 0.3 when working in Julia, take a look at the Dates
package. Add this to the environment with Pkg.add("Dates")
(it provides a subset of the functionality of the Dates
module mentioned next). There is also the Time
package by Quinn Jones. Take a look at the docs to see how to use it (https://github.com/quinnj/Datetime.jl/wiki/Datetime-Manual).
Starting from Julia Version...