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
  • 3,123
  • 2
  • 20
  • 41
Alan Omar
  • 4,023
  • 1
  • 9
  • 20
  • 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
  • 81,458
  • 17
  • 76
  • 113