[英]Convert DateTime String with TimeZone to the DateTime with TimeZone Or in UTC in rails 3
我以下列格式从Fedex收到了DateTime字符串
"2012-06-22T21:39:48-05:00"
我想将此字符串转换为TimeZone,例如: -
Fri, 23 Jun 2012 02:39:48 +0000
是否有任何方法可以直接将此字符串转换为utc时间?
我想要类似于以下内容
date_and_time = '%m-%d-%Y %H:%M:%S %Z'
DateTime.strptime("2012-06-22T21:39:48 Central Time (US & Canada)", date_and_time)
这是你在找什么?
DateTime.parse("2012-06-22T21:39:48-05:00").utc
或者我错过了什么?
干得好 :
"2012-06-22T21:39:48-05:00".to_time.utc.strftime("%a, %d %b %Y %T %z")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.