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?
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.
in Ruby:
>> Time.now.to_i
=> 1248933648
curl icanhazepoch.com
Basically it's unix timestamps as a service (UTaaS)
In python add the following lines to get a time stamp:
>>> import time
>>> time.time()
1335906993.995389
>>> int(time.time())
1335906993