Python - get UTC offset by seconds

Based on this code, how do I get the UTC offset of a given date by seconds. get UTC offset from time zone name in python

Currently, I have this code:

Python 2.7.3 (default, Jul  3 2012, 19:58:39) 
[GCC 4.7.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> import datetime
>>> offset ='US/Pacific')).strftime('%z')
>>> offset
>>> int(offset)*3600
>>> int(offset)*360 

For example, US/Pacific sometimes is -800 hours (probably military time :D) but I need it to be in seconds, ex: -25200.

Shall I just multiply it by 360? Doesn't sound right but who knows.



>>> import datetime, pytz
>>> melbourne = pytz.timezone("Australia/Melbourne")
>>> melbourne.utcoffset(
datetime.timedelta(0, 36000)

>>> pacific = pytz.timezone("US/Pacific")
>>> pacific.utcoffset(
datetime.timedelta(-1, 61200)
>>> -1*86400+61200
>>> pacific.utcoffset(

Need Your Help

Global array allocation — stack or heap?

c++ c visual-studio stack heap

I'm compiling the following using Visual Studio 2008 for Windows.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.