aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders/date_time.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/json/encoders/date_time.rb')
-rw-r--r--activesupport/lib/active_support/json/encoders/date_time.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/encoders/date_time.rb b/activesupport/lib/active_support/json/encoders/date_time.rb
index f0b0434412..380361c360 100644
--- a/activesupport/lib/active_support/json/encoders/date_time.rb
+++ b/activesupport/lib/active_support/json/encoders/date_time.rb
@@ -1,5 +1,10 @@
class DateTime
- def to_json(options = nil) #:nodoc:
+ # Returns a JSON string representing the datetime.
+ #
+ # ==== Example:
+ # DateTime.civil(2005,2,1,15,15,10).to_json
+ # # => "2005/02/01 15:15:10 +0000"
+ def to_json(options = nil)
%("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
end
end