Created
May 22, 2013 07:27
-
-
Save marsz/5625833 to your computer and use it in GitHub Desktop.
rails 更改預設的 dateformat Ref: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/DateTime.html#method-i-strftime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/application.rb | |
module MyApp | |
class Application < Rails::Application | |
... | |
Time::DATE_FORMATS.merge!(:default => "%Y-%m-%d %H:%M", :ymd => "%Y-%m-%d", :md => "%m/%d", :week_day => "%u") | |
... | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.last.created_at.to_s(:ymd) | |
Time.now.to_s(:week_day) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment