Skip to content

Instantly share code, notes, and snippets.

@Granitosaurus
Created February 24, 2020 07:48
Show Gist options
  • Save Granitosaurus/fdbaac3fe2703e1af5e0beb6148bec30 to your computer and use it in GitHub Desktop.
Save Granitosaurus/fdbaac3fe2703e1af5e0beb6148bec30 to your computer and use it in GitHub Desktop.
Infer date format from date string in python
somedate = '2020-02-24 07:22'
somedates = ['2020-02-24 07:22', '1995-12-01 22:00', '2001-01-01 11:54']
import dateinfer
print(dateinfer.infer(somedate)
#'%H' incorrect
print(dateinfer.infer(somedates)
#'%Y-%m-%d %H:%M' correct!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment