-1

I have datetime a string "20160713161212". It is a datetime in string with format YYYYMMDDHHIISS How to parse it to string with format "07/13/2016 16:12:12" in Python?

989
  • 12,579
  • 5
  • 31
  • 53
NamLe
  • 1
  • 1

1 Answers1

2

I think that's what you are looking for:

from datetime import datetime
dt = datetime.strptime('20160713161212', '%Y%m%d%H%M%S')
new_dt = dt.strftime("%Y/%m/%d %H:%M:%S")

For further info you can take a look here

Yonatan Kiron
  • 2,718
  • 1
  • 20
  • 25