From: Hassan Schroeder Date: 2012-08-30T09:48:01+09:00 Subject: Re: how do extract timezone from datetime object? On Wed, Aug 29, 2012 at 5:32 PM, Dan Quach wrote: > I'm working on an external interface where a partner website is giving >>> dt = DateTime.parse( "Wed, 29 Aug 2012 17:26:44 -0700" ) > => Wed, 29 Aug 2012 17:26:44 -0700 >>> dt.strftime( "%z" ) > => "-0700" > > What I have to do is extract the UTC time zone. So in the prior example > I need an integer of -7. (UTC-7) in this scenario. 1.9.3p194 :013 > dt.zone => "-07:00" 1.9.3p194 :014 > dt.zone.to_i => -7 1.9.3p194 :015 > HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan