我有約會減法的問題在Ruby中紅寶石日期減法
"2011-03-29".to_date - "2011-03-20".to_date #=> (9/1)
("2011-03-29".to_date - "2011-03-20".to_date).to_i #=> 9
似乎它返回的天數日期之間的差值。
現在我的問題是返回的年數,月,日差
ie ("2011-03-29".to_date - "2011-03-20".to_date)
的日子應該返回
0 years, 0 month and 9 days
感謝。
你正在使用哪種庫或框架,爲字符串提供'to_date'方法? Rails的?還有別的嗎? – maerics 2011-03-29 08:23:37