Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Created November 2, 2021 06:28
Show Gist options
  • Save Mulperi/065c87e990f03cc3d76cfcbc9283c41f to your computer and use it in GitHub Desktop.
Save Mulperi/065c87e990f03cc3d76cfcbc9283c41f to your computer and use it in GitHub Desktop.
python datetime object remove microseconds
from datetime import datetime, date, time, timezone
dt = datetime.utcnow()
print(dt)
newtime = dt.replace(microsecond=0)
print(newtime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment