How to get only days or months when two dates are differentiated?
if possible to get days or months using ruby? please give me the
solution?
Thanks
How to get only days or months when two dates are differentiated?
if possible to get days or months using ruby? please give me the
solution?
Thanks
I don’t think I understand you, but let’s try…
irb(main):001:0> t1 = Time.now
=> 2011-08-19 17:50:59 +0200
irb(main):004:0> t2 = Time.utc 2011, 1, 1
=> 2011-01-01 00:00:00 UTC
irb(main):005:0> t1 - t2
=> 19929059.71875
irb(main):006:0> (t1 - t2) / (606024)
=> 230.66041341145834
The above is number of days the dates differ. To get months, divide it
once more by 30.
– Matma R.
2011/8/19 Kapil K. [email protected]:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs