-1

I want to print date format when I type numbers but when I use module dateutil parser it prints date with time, but I want only date. How to do it? The code:

from dateutil import parser

data3 = parser.parse(input("Date of birth (yyyymmdd): "))
print(data3)

Output:

1900-12-23 00:00
martineau
  • 119,623
  • 25
  • 170
  • 301
Maria
  • 117
  • 9
  • Your posted code prints nothing: it hangs waiting for input. We are not going to provide your test data. What happened when you tried to specify your desired format, per `dateutil` documentation? Please supply the expected [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Show where the intermediate results differ from what you expected. – Prune Aug 17 '20 at 21:54
  • I think nothing happened I just forgot to add print(data3). – Maria Aug 17 '20 at 21:58

1 Answers1

2

Use the strftime function with the following parameters

from dateutil import parser
data3 = parser.parse(input("Date of birth (yyyymmdd): "))
data3.strftime('%m-%d-%Y')
Jacob K
  • 742
  • 6
  • 13