我有一個開始月份(3),開始年份(2004年),並且我有一個結束年份(2008年)。我想計算開始和結束日期之間的單詞時間。這就是我想和它不工作..在Rails中使用distance_of_time_in_words
# first want to piece the start dates together to make an actual date
# I don't have a day, so I'm using 01, couldn't work around not using a day
st = (start_year + "/" + start_month + "/01").to_date
ed = (end_year + "/01/01").to_date
# the above gives me the date March 1st, 2004
# now I go about using the method
distance_of_time_in_words(st, ed)
..this拋出一個錯誤,「字符串就不是我強迫Fixnum對象」。任何人看到這個錯誤?
謝謝,我試過第二個選項,簡短。 – absolutskyy