同样,我是条纹新手。我在本节中使用Rails而没有JS,我想在我的应用程序中显示向客户收费的时间。 In the charge JSON,我看到了这一点:"created": 1461761985,
。
所以在我的循环中,(缩短):
...
<%= c.created.strftime() %>
...
1461761985的未定义方法`strftime':Fixnum
我以为我可以使用strftime,但错误很少。有没有办法在Rails 4中将此时间格式转换为D-M-Y
?
答案 0 :(得分:1)
如果我没错,这是一个unix时间戳。试试这些:
DateTime.strptime(c.created.to_s, '%s')
# or
Time.at(c.created).to_datetime