Skip to content

Instantly share code, notes, and snippets.

@leewind
Created January 12, 2020 14:06
Show Gist options
  • Select an option

  • Save leewind/724358a7f84bcddf12a3915cc5b97c52 to your computer and use it in GitHub Desktop.

Select an option

Save leewind/724358a7f84bcddf12a3915cc5b97c52 to your computer and use it in GitHub Desktop.
python string to datetime
from datetime import datetime
datetime_str = '09/19/18 13:55:26'
datetime_object = datetime.strptime(datetime_str, '%m/%d/%y %H:%M:%S')
print(type(datetime_object))
print(datetime_object) # printed in default format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment