Sunday, August 12, 2012

ruby rails - examples for date time helpers

with the time helpers it is amazingly easy to deal with dates and times (add, diff...)

$ rails console
  >> 1.year.from_now
  => Sun, 13 Mar 2011 03:38:55 UTC +00:00
  >> 10.weeks.ago
  => Sat, 02 Jan 2010 03:39:14 UTC +00:00
  >> 1.hour.from_now
  => Sun, 12 Aug 2012 09:52:39 UTC +00:00 
  >> 30.seconds.from_now
  => Sun, 12 Aug 2012 08:54:00 UTC +00:00 
 

No comments :

Post a Comment