Alex
Alex

Reputation: 536

How to convert a specific integer to datetime in python

For example, I have the int 043017, which I want converted to 04/30/17 (April 30, 2017), I want to be able to convert any int of that format into datetime, how can this be accomplished?

Upvotes: 6

Views: 6354

Answers (1)

mohammad
mohammad

Reputation: 2198

import datetime
d = datetime.datetime.strptime(input, '%m%d%y')

Upvotes: 7

Related Questions