Reputation: 28800
If I have a ruby time instance, how can I format it so that it can be formatted into the following:
2014-09-19T15:40:24Z
Upvotes: 1
Views: 48
Reputation: 20015
You can do the following:
require 'time'
Time.now.utc.iso8601
# => "2015-04-26T20:51:06Z"
You can convert also back from a string in iso8601
format to a time instance:
Time.iso8601("2015-04-26T20:51:06Z")
# => 2015-04-26 20:51:06 UTC
Upvotes: 2
Reputation: 7211
You're probably looking for Time#iso8601
. You may need to run .utc
first if you don't want a timezone at the end.
Upvotes: 2