Jan-31-2020, 06:11 PM
I would like to convert string in to date format which is acceptable by elasticsearch
doc = {
'submitted': '2020-01-25 20:10:10',
'num': '2',
'timestamp': 1579624522874,
}
I have two field submitted and timestamp
timestamp I was able to convert using following and elasticsearch took it as timestamp.
datetime.fromtimestamp(int(doc['timestamp'])/1000).strftime('%Y-%m-%d %H:%M:%S')
but submitted I have to convert in to isoformat which I can't seems to get it working.
I also want to add timezone "Etc/UTC" to it.
doc = {
'submitted': '2020-01-25 20:10:10',
'num': '2',
'timestamp': 1579624522874,
}
I have two field submitted and timestamp
timestamp I was able to convert using following and elasticsearch took it as timestamp.
datetime.fromtimestamp(int(doc['timestamp'])/1000).strftime('%Y-%m-%d %H:%M:%S')
but submitted I have to convert in to isoformat which I can't seems to get it working.
I also want to add timezone "Etc/UTC" to it.