I have following time stamp received as event to the lambda function where i need to extract the date from the timestamp
import datetime as dt
case1_time=2021-06-23T00:05:05-04:00
case2_time=2021-08-03T04:57:52.30-04:00
def get_date_from_ts(timestamp):
extracted_date=dt.datetime.fromisoformat(timestamp)
#case 1
print(get_date_from_ts(case1_time))
## This will extract the date as = 2021-06-23
#case2
print(get_date_from_ts(case2_time))
ValueError: Invalid isoformat string
i need to handle both case by the way.. can anyone help how to resolve this format issue?