I am searching nearly 2 days, how to convert this type of timestamp format: 2018-07-11T10:40:09+00:00 gathered from excel cell to an epoch?
The code I use is this:
import openpyxl
import datetime
from datetime import date, datetime, time
path = "/home/UbuntuUser/Desktop/Times.xlsx"
wb_obj = openpyxl.load_workbook(path)
sheet_obj = wb_obj.active
cell_obj = sheet_obj.cell(row = 2, column = 3)
print(cell_obj.value)
print(datetime.fromisoformat(cell_obj.value))
print(time.mktime(datetime.fromisoformat(cell_obj.value)))
which does not work! (source: https://www.kite.com/python/answers/how-to-convert-the-current-date-to-an-epoch-timestamp-in-python and https://www.geeksforgeeks.org/python-reading-excel-file-using-openpyxl-module/)
I read this post: How to convert python timestamp string to epoch?
and I tried to use this code:
from datetime import datetime
p = '%Y-%m-%dT%H:%M:%S.%fZ'
mytime = "2009-03-08T00:27:31.807Z"
epoch = datetime(1970, 1, 1)
print((datetime.strptime(mytime, p) - epoch).total_seconds())
but the format of what I read is different, and it does not work... Any idea??