Asrarahmed Kadri wrote:
> Hi ,
>  
>  
> I have a question:
>  
> Is it possible to add seconds to a datetime object and get the result as 
> a new datetime object. I mean when we keep adding, for example, 3600 
> seconds, the date will get changed after 24 iterations. Is it possible 
> to carry out such an operation ?

Sure, just add a datetime.timedelta to the datetime object:

In [1]: from datetime import datetime, timedelta

In [2]: d=datetime.now()

In [3]: d
Out[3]: datetime.datetime(2006, 11, 18, 9, 47, 31, 187000)

In [4]: delta=timedelta(seconds=3600)

In [5]: d+delta
Out[5]: datetime.datetime(2006, 11, 18, 10, 47, 31, 187000)

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to