Get date and time as Unix epoch

From Cuis CookBook
Revision as of 20:26, 4 May 2025 by Nmingott (talk | contribs) (imported material)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.