Python Datetime Remove Millliseconds and Seconds (or time)

February 21, 2021

Remove second and milliseconds

import datetime

now = datetime.datetime.now().replace(second=0, microsecond=0)

Remove time

now = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.