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
···
--
Posted via http://www.ruby-forum.com/.
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
--
Posted via http://www.ruby-forum.com/.
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) / (60*60*24)
=> 230.66041341145834
The above is number of days the dates differ. To get months, divide it
once more by 30.
-- Matma Rex
2011/8/19 Kapil K. <kapil_kumar_517@yahoo.in>:
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
--
Posted via http://www.ruby-forum.com/\.