Learning Ruby

How to get the time when a file was last modified

file = "test/foo.html"

last_mod_time = File.mtime( file ) 
# => 2010-01-05 09:40:01 -0800
pretty_time = last_mod_time.strftime("%B %d, %Y at %l:%M %P")
# => "January 05, 2010 at 9:40 am"

 

 

January 05, 2010 at 9:40 am