-2

In my django app I am getting the date returned in the following format

2021-01-05T23:19:30.685658Z

How do I convert this to dd-mm-yyyy?

Yantra Logistics
  • 116
  • 1
  • 14

1 Answers1

0

you can use

from datetime import datetime
dt = datetime.fromisoformat('2021-01-05T23:19:30.685658Z'[:-1])
dt = dt.strftime('%Y-%m-%d')
print(dt)

result will be 2021-01-05

Sohaib
  • 490
  • 3
  • 12