2011-05-16 85 views
0

从我的散列的输出是给我下面的日期时间:格式化日期输出散列

16 May 11 13:12:14 +0000 

如何去格式化成什么明智的吗?

感谢

+2

什么是 “我的哈希值”?你期望什么是合理的时间?这是一个Rails项目吗?只有Ruby? – 2011-05-17 01:50:13

+1

问题的轨道上标记红宝石? – 2011-05-17 23:08:54

回答

1

我会假设你是想在一个视图这个输出...首先,你可以创建一些格式:

# /config/locales/en.yml: 
en: 
    date: 
    formats: 
     full: "%b %d, %Y" 

    time: 
    formats: 
     full: "%B %d, %Y at %I:%M%p" 

然后你就可以在视图中使用显示日期时间l方法与指定的格式:

<%= l @something.updated_at, :format => :full %> 

这将显示类似如下:

May 16, 2011 at 01:12pm 

More on the i18n formats

List of available directives

+0

非常感谢,非常感谢。会给它一个镜头。乙 – 2011-05-17 23:09:26