ruby - ROR + 不同格式的 Ruby 日期

标签 ruby ruby-on-rails-3 postgresql date

如果我有 @today = Thu Apr 21 2011 00:00:00 GMT 0530 (IST),

如何将 @today 转换为 "Thur April 21, 2011"

最佳答案

Time.now.strftime("%a %B %d, %Y")
=> "Fri April 15, 2011"

在你的场合:

@today.to_time.strftime("%a %B %d, %Y")
=> "Thu April 21, 2011"

关于ruby - ROR + 不同格式的 Ruby 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5674260/

相关文章:

ruby-on-rails - 收到 Uid 和 authtoken 时创建 facebook session

ruby-on-rails - 应该 "be valid"做失败与 "' handle_matcher' : undefined method 'matches?' "

postgresql - 如何解决 postgres psql 命令中的这个问题?

mysql - 在 Rails 应用程序中管理 2 个不同的数据库模式

ruby-on-rails - rails : Helper Refactoring

ruby-on-rails - rspec 可以输出使测试失败的值吗?

ruby-on-rails - Activerecord Force Index 包括

ruby-on-rails - Rails3 嵌套属性在保存操作中使用父值

postgresql - 如何在具有较新版本的系统上从旧版本的 PostGIS 恢复数据库转储?

sql - 将 ActiveRecord 查询重写为递归 SQL