convert datestring to ISODate format: for ex: 11-05-2020 --- > 2020-05-11 16:05:58.970Z
You can use the datetime
module to convert between strings and datetime objects.
For example to read the string, you can prescribe what the format is
>>> from datetime import datetime
>>> d = datetime.strptime('11-05-2020', '%d-%m-%Y')
>>> d
datetime.datetime(2020, 5, 11, 0, 0)
Then using this datetime object you can convert to another string representation
>>> d.isoformat()
'2020-05-11T00:00:00'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.