日期时间的strftime

Twi*_*ddr 1 ruby-on-rails date strftime

我得到了以下代码,我想将其转换为特定格式的字符串.但我无法让它发挥作用.

Date.today + warning.notify_time_close.seconds
Run Code Online (Sandbox Code Playgroud)

我想做的事情就是这样,但它不起作用:)

(Date.today + warning.notify_time_close.seconds).strftime "%d-%m-%Y %H:%M:%S"
Run Code Online (Sandbox Code Playgroud)

我知道它简单但只是不知道该怎么做:)

提前致谢!

肯尼斯

Mis*_*cha 5

这不应该是必要的,但作为一种解决方法,您可以尝试这样做:

Time.at(
    Date.today.to_time.to_i + warning.notify_time_close.seconds
).strftime("%d-%m-%Y %H:%M:%S")
Run Code Online (Sandbox Code Playgroud)