Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'syntax': 0.03; 'mrab': 0.05; 'used.': 0.07; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'sits': 0.16; 'subject:issue': 0.16; 'utc': 0.16; 'wrote:': 0.17; 'written': 0.20; 'cc:2**0': 0.23; 'this:': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'correct': 0.28; 'skip:( 20': 0.28; 'programming,': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'server': 0.35; 'received:209.85': 0.35; 'add': 0.36; 'but': 0.36; "didn't": 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'instead': 0.39; 'easily': 0.39; 'where': 0.40; 'from:no real name:2**0': 0.60; 'time,': 0.62; 'between': 0.63; 'more': 0.63; 'hours': 0.66; 'reply': 0.66; '8bit%:100': 0.70; '8bit%:92': 0.70; 'attention': 0.75; 'as:': 0.75 Newsgroups: comp.lang.python Date: Sun, 16 Sep 2012 08:40:42 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.68.84.56; posting-account=kVzDWgoAAAC3X_KbKNwatTH78f6TU1UN References: <52847c35-388c-4758-b72d-1d1859b788a3@googlegroups.com> <8370412f-5176-45ff-87eb-72cbca5149d5@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.68.84.56 MIME-Version: 1.0 Subject: Re: datetime issue From: pandora.koura@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 69 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347810046 news.xs4all.nl 6922 [2001:888:2000:d::a6]:59242 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29318 =CE=A4=CE=B7 =CE=9A=CF=85=CF=81=CE=B9=CE=B1=CE=BA=CE=AE, 16 =CE=A3=CE=B5=CF= =80=CF=84=CE=B5=CE=BC=CE=B2=CF=81=CE=AF=CE=BF=CF=85 2012 6:30:15 =CE=BC.=CE= =BC. UTC+3, =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 MRAB =CE=AD= =CE=B3=CF=81=CE=B1=CF=88=CE=B5: > On 2012-09-16 09:25, =CE=9D=CE=B9=CE=BA=CF=8C=CE=BB=CE=B1=CE=BF=CF=82 =CE= =9A=CE=BF=CF=8D=CF=81=CE=B1=CF=82 wrote: >=20 > [snip] >=20 > > >=20 > > date =3D ( datetime.datetime.now() + datetime.timedelta(hours=3D8) ).st= rftime( '%y-%m-%d %H:%M:%S') >=20 > > >=20 > > but iam giving +8 hours which is the time difference between texas, us = where the server sits and Greece's time. >=20 > > >=20 > > cant we somehow tell it to use GMT+2 ? >=20 > > >=20 > > also it would be nice if datetime.datetime.now(GMT+2) can be used. >=20 > > >=20 > In programming, you need attention to details. >=20 >=20 >=20 > My reply didn't use datetime.datetime.now(), it used=20 >=20 > datetime.datetime.utcnow(). >=20 >=20 >=20 > datetime.datetime.now() gives the local time (local to the system on=20 >=20 > which it is running). >=20 >=20 >=20 > datetime.datetime.utcnow() gives the UTC (GMT) time, which is the same=20 >=20 > everywhere. >=20 >=20 >=20 > The line should be this: >=20 >=20 >=20 > date =3D (datetime.datetime.utcnow() + datetime.timedelta(hours=3D8)=20 >=20 > ).strftime('%Y-%m-%d %H:%M:%S') >=20 >=20 >=20 > I've also used '%Y' instead of '%y' because I prefer 4 digits for the yea= r. Cant it be written more easily as: date =3D (datetime.datetime.utcnow(+2) i know this is not thhe correct syntax but it just needs a way to add GMT+2= hours since utc=3Dgmt