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? 回答1: 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. 回答2: in Ruby: >> Time.now.to_i => 1248933648 回答3: In python add the