Counting the Days Since an Arbitrary Date : Date Calculation « Date « Ruby
- Ruby
- Date
- Date Calculation
Counting the Days Since an Arbitrary Date
require 'date'
def last_modified(file)
t1 = File.stat(file).ctime
t2 = Time.now
elapsed = (t2-t1)/(60*60*24)
puts "#{file} was last modified #{elapsed} days ago."
end
last_modified("c:\\")
Related examples in the same category