JP Silvashy
JP Silvashy

Reputation: 48535

Rails, for each second in past week

I want to do something for each second in the past week and pass in the current epoch time as well... I'm not sure how to do this, but it seems really trivial, here is my pseudo code:

1.week.ago..Time.now do |second|
  puts second
end

How would I make this output the current time in ints for each second in that range?

Upvotes: 4

Views: 226

Answers (1)

Linus Oleander
Linus Oleander

Reputation: 18137

How about

(1.week.ago.to_i..Time.now.to_i).each{ |second| puts "second=#{second}"}

Upvotes: 6

Related Questions