python set day of date to 1

Solutions on MaxInterview for python set day of date to 1 by the best coders in the world

showing results for - "python set day of date to 1"
Stéphane
08 Sep 2016
1from datetime import datetime
2
3your_date = datetime.strptime('26 June 2021', '%d %b %Y')
4# Using the .replace() method:
5newdatetime = your_date.replace(day=1)
6# 2021-06-01 00:00:00