[python-win32] datetime.datetime.now(tz=WHAT?????)

Vernon Cole kf7xm at netscape.net
Wed Jun 2 18:16:21 EDT 2004


I suppose that there is an easy answer to this question... if I only 
could find the correct document to read.
Environment: Python 2.3.4    on  Windows2000
Application:  Trying to construct a date string for use by 
smtplib.sendmail()
    ... It should look like: "27 Aug 2020 09:32:31 MDT"
    ... or "27 Aug 2020 09:32:31 +0700"
What I have tried (latest vain attempt):
    import datetime
    date = datetime.datetime.strftime(
        datetime.datetime.now(),
        '%d %b %Y %H:%M:%S %z')
    print date

The date prints WITHOUT TIME ZONE -- as documented.
In order to print the timezone I must provide an object of type tzinfo 
to supply to
datetime.datetime.now(tz= ????)  .

Questions: 1)    I could hard code the timezone, but the documents show 
only use of tz=None, which is the not helpful.  How do I create an 
instance of a tzinfo for a specific time zone?

2)    Windows already knows my timezone.   How do I get it so that I can 
plug it in?

3) Am I trying a completly wrong approach and should be using some other 
module?

----------
Vernon





More information about the Python-win32 mailing list