How to convert a unix timestamp (seconds since epoch) to Ruby DateTime?

后端 未结 6 632
孤城傲影
孤城傲影 2020-11-30 16:21

How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?

6条回答
  •  被撕碎了的回忆
    2020-11-30 17:02

    If you wanted just a Date, you can do Date.strptime(invoice.date.to_s, '%s') where invoice.date comes in the form of anFixnum and then converted to a String.

提交回复
热议问题