How to round down datetime to previous hour? for example:
print datetime.now().replace(microsecond=0) >> 2017-01-11 13:26:12.0
round
from datetime import datetime, timedelta n = datetime.now() - timedelta(hours=1) new_date = datetime(year=n.year, month=n.month, day=n.day, hour=n.hour)