1

I have a python list of dates in the format of 2014-07-06 11:03:12 is there a way to change the seconds and minutes to 2014-07-06 11:00:00 in a nice way. My line of code for getting the dates in below

dates = [datetime.datetime.strptime (d, '%Y-%m-%d %H:%M:%S') for d in df.date] `2014-07-06 11:03:12` format
Ahmed
  • 292
  • 1
  • 7
  • 15

2 Answers2

3
from datetime import datetime, timedelta

print(datetime.now().replace(microsecond=0,second=0,minute=0)-timedelta(hours=1))
Aditya_kr
  • 175
  • 1
  • 13
1

strptime(..).strftime('%Y-%m-%d %H:00:00')

Adding this to the line as commented by Wondercricket gave me the solution I was looking for.

Ahmed
  • 292
  • 1
  • 7
  • 15