How can I generate Unix timestamps?

Léo Léopold Hertz 준영 picture Léo Léopold Hertz 준영 · Jul 30, 2009 · Viewed 291.1k times · Source

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?

Answer

Naresh picture Naresh · Sep 7, 2012

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.