Get date and time as Unix epoch

From Cuis CookBook
Jump to navigation Jump to search

Problem. You want the current date and time as a Unix epoch. That is, roughly speaking, as number of seconds since 01-Jan-1970.

Solution.

DateAndTime now unixTimeSeconds .    "=> 1629056092 "

Exercise. Get the same number running the Linux date command as an external program.

Exercise. Read the method DateAndTime#unitTimeSeconds.