A common requirement in programs is getting the number of seconds, milliseconds, or nanoseconds since the Unix epoch. Here’s how to do it in Julia.
Use now() to get the current time, and then use datetime2unix() to convert it to seconds since the Unix epoch. Multiply by 1000 or 1e9 to get milliseconds or nanoseconds, respectively.
You can also convert integer seconds since the epoch back into the corresponding DateTime using unix2datetime().
To run the program:
Next, we’ll look at another time-related task: time parsing and formatting.