Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- now = datetime.now()
- def rounder(t):
- h = t.hour
- if t.minute >= 30:
- return t.replace(minute=0, hour=h+1)
- else:
- return t.replace(minute=0)
- now # 2018-02-22 22:03:53.831589
- rounder(now) # 2018-02-22 22:00:53.831589
Add Comment
Please, Sign In to add comment