Reputation: 10744
I have this DateTime
format:
var1 = 2014-06-10T18:49:59+00:00
and I want convert to this format:
var2 = 2014-06-10 18:49:59 UTC
Thanks!
Upvotes: 1
Views: 4303
Reputation: 15788
Try:
Time.parse(var1.to_s).utc
Assuming var1 holds a DateTime object.
Upvotes: 3
Reputation: 11638
Use strftime:
var2 = var1.strftime("%Y-%m-%d %H:%M:%S %z")
see the strftime documentation for more format strings
http://www.ruby-doc.org/core-2.0/Time.html
Upvotes: 0