Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > datetime issue

Reply
Thread Tools

datetime issue

 
 
Guest
Posts: n/a
 
      09-16-2012
dn = datetime.datetime.now()
dd = datetime.timedelta(hours=2)
date = dn + dd
date = date.strftime( '%y-%m-%d %H:%M:%S' )

still giving me texas,us time for some reason
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      09-16-2012
, 16 2012 10:51:18 .. UTC+3, :
> dn = datetime.datetime.now()
>
> dd = datetime.timedelta(hours=2)
>
> date = dn + dd
>
> date = date.strftime( '%y-%m-%d %H:%M:%S' )
>
>
>
> still giving me texas,us time for some reason


which is same as this:

date = ( datetime.datetime.now() + datetime.timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S')

this also doesnt work either:

date = ( datetime.datetime.now(hours=2).strftime( '%y-%m-%d %H:%M:%S')

if only it would!
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      09-16-2012
, 16 2012 10:51:18 .. UTC+3, :
> dn = datetime.datetime.now()
>
> dd = datetime.timedelta(hours=2)
>
> date = dn + dd
>
> date = date.strftime( '%y-%m-%d %H:%M:%S' )
>
>
>
> still giving me texas,us time for some reason


which is same as this:

date = ( datetime.datetime.now() + datetime.timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S')

this also doesnt work either:

date = ( datetime.datetime.now(hours=2).strftime( '%y-%m-%d %H:%M:%S')

if only it would!
 
Reply With Quote
 
Guest
Posts: n/a
 
      09-16-2012
Τη Κυριακή, 16 Σεπτεμβρίου 2012 8:53:57 π.μ. UTC+3, ο χρήστης Dennis Lee Bieber *γραψε:
> On Sat, 15 Sep 2012 22:15:38 -0700 (PDT), Íéêüëáïò Êïýñáò
>
> <> declaimed the following in
>
> gmane.comp.python.general:
>
>
>
>
>
> >

>
> > If i wanted to alter the following line, how would i write it?

>
> >

>
> > date = datetime.datetime.now()+datetime.timedelta(hours=2 ).strftime( '%y-%m-%d %H:%M:%S')

>
> >

>
> > But that doesnt work,

>
>
>
> What did you expect? Object methods bind tighter than operators so
>
> what you have is the equivalent of
>
>
>
> dn = datetime.datetime.now()
>
> dd = datetime.timedelta(hours=2).strftime(...)
>
> date = dn + dd
>
>
>
> Try
>
>
>
> >>> import datetime

>
> >>> date = datetime.datetime.now()+datetime.timedelta(hours=2 ).strftime( '%y-%m-%d %H:%M:%S')

>
> Traceback (most recent call last):
>
> File "<interactive input>", line 1, in <module>
>
> AttributeError: 'datetime.timedelta' object has no attribute 'strftime'
>
> >>> date = (datetime.datetime.now()+datetime.timedelta(hours= 2) ).strftime( '%y-%m-%d %H:%M:%S')

>
> >>> date

>
> '12-09-16 03:50:44'
>
> >>>

>
>
>
> Note the ( ) wrapping the the + clause, with strftime() applied to
>
> the result of that...
>
> --
>
> Wulfraed Dennis Lee Bieber AF6VN
>
> HTTP://wlfraed.home.netcom.com/




date = ( datetime.datetime.now() + datetime.timedelta(hours= ).strftime( '%y-%m-%d %H:%M:%S')

but iam giving +8 hours which is the time difference between texas, us where the server sits and Greece's time.

cant we somehow tell it to use GMT+2 ?

also it would be nice if datetime.datetime.now(GMT+2) can be used.
 
Reply With Quote
 
Guest
Posts: n/a
 
      09-16-2012
Τη Κυριακή, 16 Σεπτεμβρίου 2012 8:53:57 π.μ. UTC+3, ο χρήστης Dennis Lee Bieber *γραψε:
> On Sat, 15 Sep 2012 22:15:38 -0700 (PDT), Íéêüëáïò Êïýñáò
>
> <> declaimed the following in
>
> gmane.comp.python.general:
>
>
>
>
>
> >

>
> > If i wanted to alter the following line, how would i write it?

>
> >

>
> > date = datetime.datetime.now()+datetime.timedelta(hours=2 ).strftime( '%y-%m-%d %H:%M:%S')

>
> >

>
> > But that doesnt work,

>
>
>
> What did you expect? Object methods bind tighter than operators so
>
> what you have is the equivalent of
>
>
>
> dn = datetime.datetime.now()
>
> dd = datetime.timedelta(hours=2).strftime(...)
>
> date = dn + dd
>
>
>
> Try
>
>
>
> >>> import datetime

>
> >>> date = datetime.datetime.now()+datetime.timedelta(hours=2 ).strftime( '%y-%m-%d %H:%M:%S')

>
> Traceback (most recent call last):
>
> File "<interactive input>", line 1, in <module>
>
> AttributeError: 'datetime.timedelta' object has no attribute 'strftime'
>
> >>> date = (datetime.datetime.now()+datetime.timedelta(hours= 2) ).strftime( '%y-%m-%d %H:%M:%S')

>
> >>> date

>
> '12-09-16 03:50:44'
>
> >>>

>
>
>
> Note the ( ) wrapping the the + clause, with strftime() applied to
>
> the result of that...
>
> --
>
> Wulfraed Dennis Lee Bieber AF6VN
>
> HTTP://wlfraed.home.netcom.com/




date = ( datetime.datetime.now() + datetime.timedelta(hours= ).strftime( '%y-%m-%d %H:%M:%S')

but iam giving +8 hours which is the time difference between texas, us where the server sits and Greece's time.

cant we somehow tell it to use GMT+2 ?

also it would be nice if datetime.datetime.now(GMT+2) can be used.
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      09-16-2012
On Sun, 16 Sep 2012 01:25:30 -0700, Νικόλαος Κούρας wrote:
[...]

You seem to be emailing python-list AND posting to comp.lang.python (or
the gmane mirror). Please pick one, or the other, and not both, because
the mailing list and the newsgroup are mirrors of each other. Anything
you send to the mailing list will be mirrored on the newsgroup
automatically, there is no need to manually duplicate the post.


Thank you.


--
Steven
 
Reply With Quote
 
Guest
Posts: n/a
 
      09-16-2012
, 16 2012 12:53:42 .. UTC+3, Steven D'Aprano :
> On Sun, 16 Sep 2012 01:25:30 -0700, wrote:
>
> [...]
>
>
>
> You seem to be emailing python-list AND posting to comp.lang.python (or
>
> the gmane mirror). Please pick one, or the other, and not both, because
>
> the mailing list and the newsgroup are mirrors of each other. Anything
>
> you send to the mailing list will be mirrored on the newsgroup
>
> automatically, there is no need to manually duplicate the post.
>
>
>
>
>
> Thank you.
>
>
>
>
>
> --
>
> Steven


Iam sorry i didnt do that on purpose and i dont know how this is done.

Iam positng via google groups using chrome, thats all i know.

Whats a mailing list?
Can i get responses to my mail instead of constantly check the google groups site?
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      09-16-2012
On Sun, 16 Sep 2012 03:15:11 -0700, Νικόλαος Κούρας wrote:

> Whats a mailing list?
> Can i get responses to my mail instead of constantly check the google
> groups site?


http://mail.python.org/mailman/listinfo/python-list



--
Steven
 
Reply With Quote
 
Guest
Posts: n/a
 
      09-16-2012
, 16 2012 1:49:38 .. UTC+3, Steven D'Aprano :
> On Sun, 16 Sep 2012 03:15:11 -0700, wrote:
>
>
>
> > Whats a mailing list?

>
> > Can i get responses to my mail instead of constantly check the google

>
> > groups site?

>
>
>
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
>
>
>
>
> --
>
> Steven


Thank you, i prefer to be notifies only to thread iam initiating or answering to not all of te threads. Is this possible?
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      09-16-2012
On Sun, 16 Sep 2012 03:54:45 -0700, Νικόλαος Κούρας wrote:

> Τη Κυριακή, 16 Σεπτεμβρίου 2012 1:49:38 μ.μ. UTC+3, ο χρήστης Steven
> D'Aprano *γραψε:
>> On Sun, 16 Sep 2012 03:15:11 -0700, Νικόλαος Κούρας wrote:
>>
>>
>>
>> > Whats a mailing list?

>>
>> > Can i get responses to my mail instead of constantly check the google

>>
>> > groups site?

>>
>>
>>
>> http://mail.python.org/mailman/listinfo/python-list


> Thank you, i prefer to be notifies only to thread iam initiating or
> answering to not all of te threads. Is this possible?


No. That's not how mailing lists work. Every email gets posted to all
members, unless they go onto "No Mail", in which case they get no emails
at all.

You are not paying anything for the help you are receiving, except to
give your own time in return to help others. We are all volunteers here,
and nobody is going to force you to volunteer in return, but if everyone
only received threads that they initiated, nobody would see new threads
and nobody would get any answers at all.



--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57