tags:

views:

51

answers:

2

now() gives me

datetime.datetime(2010, 7, 6, 5, 27, 23, 662390)

How do I get just datetime.datetime(2010, 7, 6, 5, 27, 0, 0) (the datetime object) where everything after minutes is zero?

+4  A: 
dt.replace( second=0, microsecond=0)

http://docs.python.org/library/datetime.html#datetime.datetime.replace

Forest
+3  A: 

You can use datetime.replace to obtain a new datetime object without the seconds and microseconds:

the_time = datetime.now()
the_time = the_time.replace(second=0, microsecond=0)
Joseph Spiros
or `the_time= datetime.now().replace(second=0, microsecond=0)`
ΤΖΩΤΖΙΟΥ