1

What I want to do is obtaining a new datetime object using python datetime replace() method. this works fine for most cases, however let's say the day is 31 of January 2019 23:00 PM and i executed:

datetime.now().replace(hour=datetime.now().hour + 1 )

What i want to have back is a new datetime object with hour set to 0 ,day Set to 1 and month set 2 I am new to python if the question has an obvious answer.

Sreekiran A R
  • 2,838
  • 2
  • 18
  • 38
Alan Omar
  • 3,069
  • 1
  • 8
  • 18
  • Possible duplicate of [How to increment a datetime by one day?](https://stackoverflow.com/questions/3240458/how-to-increment-a-datetime-by-one-day) – Ahmad Khan Feb 01 '19 at 10:06

1 Answers1

1

Looks like you need datetime.timedelta

Ex:

import datetime

print( datetime.datetime.now() + datetime.timedelta(hours=1))
Rakesh
  • 78,594
  • 17
  • 67
  • 103