Skip to content

Instantly share code, notes, and snippets.

@jibinpb
Last active July 7, 2018 06:45
Show Gist options
  • Save jibinpb/2d1585f2ca1f928b8eb6c4fa9d1b0c29 to your computer and use it in GitHub Desktop.
Save jibinpb/2d1585f2ca1f928b8eb6c4fa9d1b0c29 to your computer and use it in GitHub Desktop.
Extract Date from Text
from dateutil.parser import parse
from dateutil.tz import gettz
from datetime import datetime
tzinfos = {"IST": gettz("Asia/Kolkata")}
for obj in (parse("Last Updated : Jan 23, 2018 12:13 PM IST | Source: Moneycontrol.com", fuzzy_with_tokens=True, tzinfos=tzinfos)):
if(isinstance(obj, datetime)):
print(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment