Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Last active July 6, 2016 10:38
Show Gist options
  • Save brettfreer/4865ba9f7ed9b5946107eecf081d01bd to your computer and use it in GitHub Desktop.
Save brettfreer/4865ba9f7ed9b5946107eecf081d01bd to your computer and use it in GitHub Desktop.
Validate if a text string is a valid date with a supplied format string
import datetime
def isDate(date_text, fmt):
try:
datetime.datetime.strptime(date_text, fmt)
except ValueError:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment