You can clear the second and microsecond component of the datetime value, for example:
dt = datetime.datetime.now()
This will allow you to compare datetimes with minute detail.
If you want to simply print the date without a second / microsecond component, use the appropriate format string:
dt = datetime.datetime.now() print dt.strftime("%Y/%m/%d %H:%M") >>> '2012/12/12 12:12'
source share