开发者

Rails function to get "hours, minutes, seconds" until timestamp?

Have been digging around the docs but cannot find if there is a function to calculate the

As separate vars from a ruby date time stamp

Is there a build in function or does one have to calculate it by himself?


From the API docs, check out distance_of_time_in_words, I think that is what you are looking for.

For instance:

def find_time
  distance_of_time_in_words(Time.now, due_at)
end

This will calculate the length of time from now until the timestamp of due_at. You can pass the option include_seconds = true to display seconds as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜