how to convert 270921sec into days + hours + minutes + sec ? (ruby)

前端 未结 9 437
不知归路
不知归路 2020-12-02 06:09

I have a number of seconds. Let\'s say 270921. How can I display that number saying it is xx days, yy hours, zz minutes, ww seconds?

9条回答
  •  有刺的猬
    2020-12-02 06:23

    If you're using Rails, there is an easy way if you don't need the precision:

    time_ago_in_words 270921.seconds.from_now
    # => 3 days
    

提交回复
热议问题