How to obtain GMT offset?

Magnus Lycka lycka at carmen.se
Tue Aug 16 05:15:11 EDT 2005


new pip wrote:
> I'm using Windows os. If the current system date time is '28 Jun 2001
> 14:17:15 +0700', how can I obtain the value '+0700' using python?
> 
> Thank you

If you ignore the time and datetime modules, you can always split
the string on whitespace and grab the last part:

 >>> ts='28 Jun 2001 14:17:15 +0700'
 >>> tz=ts.split()[-1]
 >>> print tz
+0700



More information about the Python-list mailing list