How to obtain GMT offset?

N

new pip

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
 
E

Erik Max Francis

new said:
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?

time.timezone gives you the timezone offset in minutes.
 
J

John Machin

new said:
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?


If the current system date is in 2001, obtaining "GMT offset" is the
least of your concerns :)

Have you read the section on the time module in the Python manual?
If so, what didn't you understand?

One or more of the following might assist:

Looks like it's '-1000' (hours) for me at the moment. Daylight saving
saving isn't operating here at the moment, so I can't tell whether that
makes a difference. I haven't tried to understand the bits about DST in
the manual, but maybe you should.


HTH,
John
 
P

Peter Hansen

Erik said:
time.timezone gives you the timezone offset in minutes.

Dang, that means I'm twelve days in the past!
300
(So that would be hours? ;-) )
12

Wait up guys!

-Peter
 
B

Bengt Richter

time.timezone gives you the timezone offset in minutes.
Hm, ...

From help(time):

Variables:

timezone -- difference in seconds between UTC and local standard time
altzone -- difference in seconds between UTC and local DST time
daylight -- whether local time should reflect DST
tzname -- tuple of (standard time zone name, DST time zone name)

I learned something: there is an altzone variable. But is that a constant,
or is it zero during the standard-time part of the local year? (and since
we do not have module-level properties, what happens if you start python
during standard time and retrieve altzone after 1AM (or whenever the official
switchover happens)? Lack of property would seem to make constants for both
altzone and timezone safer. But then daylight should probably be an accessor
function, if it can't be a property ;-)

Regards,
Bengt Richter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top