Search code examples
unixunix-timestamp

How can I generate Unix timestamps?


Related question is "Datetime To Unix timestamp", but this question is more general.

I need Unix timestamps to solve my last question. My interests are Python, Ruby and Haskell, but other approaches are welcome.

What is the easiest way to generate Unix timestamps?


Solution

  • In Linux or MacOS you can use:

    date +%s
    

    where

    • +%s, seconds since 1970-01-01 00:00:00 UTC. (GNU Coreutils 8.24 Date manual)

    Example output now 1454000043.