-1
[enter image description here][1]
    # pip install python-dateutil
from datetime import datetime, date
import calendar
from dateutil.relativedelta import relativedelta

def calculatetime():
    now = datetime.today()
    print(datetime.strftime(now, "%A %B %d-%m-%Y // %H:%M:%S"))
    input_h = float(input("Input your hours: "))
    hs = now + relativedelta(hours = + input_h)
    print("Here your result : ", hs)
calculatetime()

my result is

Wednesday January 29-01-2020 // 10:44:00

Input your hours: 12

Here your result : 2020-01-29 22:44:00.752088

I want the result to look like: 29-01-2020 (dd-mm-yyyy) and 22:44:00 (hh:mm:ss)

rajah9
  • 11,645
  • 5
  • 44
  • 57
  • Welcome to StackOverflow. We can't see your image. And if your "Here (is) your result" is not in the expected format, please see https://stackoverflow.com/a/466376/509840 and choose the appropriate documentation (Python 2 or 3) and you could fix your strftime command accordingly. – rajah9 Jan 29 '20 at 11:53
  • call strftime to hs as well. `print("Here your result : ", hs.strftime("%A %B %d-%m-%Y // %H:%M:%S"))` – Vin.AI Jan 29 '20 at 12:03

1 Answers1

0

I want the result to look like: 29-01-2020 (dd-mm-yyyy) and 22:44:00 (hh:mm:ss)

Fix your formatting? If you just stringify a datetime, python will display it as ISO-8601. If you want something else, use the strftime method with the correct formatting placeholders to change the way it gets formatted.

Masklinn
  • 34,759
  • 3
  • 38
  • 57