You need to add a helper to your rails application to achieve this. Ruby does not provide a direct path for this. Below is the date processing using ruby 2.1.0.
2.1.0 :021 > a_date_time = DateTime.now
=> Fri, 26 Dec 2014 16:39:30 +0530
2.1.0 :022 > b_date_time = DateTime.now-20
=> Sat, 06 Dec 2014 16:40:03 +0530
2.1.0 :023 > (a_date_time - b_date_time).to_i
=> 19
2.1.0 :024 > Seconds = ((a_date_time - b_date_time)*24*60*60).to_i
=> 1727966
2.1.0 :025 > sec = Seconds % 60
=> 26
2.1.0 :026 > Minutes = Seconds / 60
=> 28799
2.1.0 :027 > min = Minutes % 60
=> 59
2.1.0 :028 > Hours = Minutes / 60
=> 479
2.1.0 :029 > hour = Hours % 24
=> 23
2.1.0 :030 > Days = Hours / 24
=> 19
2.1.0 :032 > Days.to_s + 'Days, ' + hour.to_s + 'Hours, '+ min.to_s + 'Mins, ' + sec.to_s + 'Secs'
=> "19Days, 23Hours, 59Mins, 26Secs"
source
share