Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to generate a migration timestamp

I am trying to generate a timestamp for rails migration that I am copying into my app from an engine as part of rake task.

The following works fine, but since rails already does the same thing, i didn't know if there is a better way to do this?

Time.now.to_s.split(" ")[0..1].join(" ").gsub!(/\D/, "")
like image 943
j_mcnally Avatar asked Oct 16 '12 00:10

j_mcnally


2 Answers

@timestamp = Time.now.strftime("%Y%m%d%H%M%S")
like image 178
Valmir Junior Avatar answered Sep 19 '22 18:09

Valmir Junior


Time.now.utc.strftime("%Y%m%d%H%M%S")
like image 45
mambo Avatar answered Sep 19 '22 18:09

mambo