简体   繁体   中英

UTC Timestamp String to UNIX timestamp

I am currently working with a given time in the following format

"2022-03-21T12:14:28.725Z"

I want to compare this time I get from the inte.net to the local datetime.datetime.utcnow().timestamp() but I can't seem to get the conversion from string to unix timestamp right. Especially with the milliseconds.

I have already tried to use datetime.fromisoformat('2022-03-21T12:14:28.725Z') but no luck there.

To better understand my situation I am doing this to check the time off-set between a Server and my local machine.

Solution: How do I translate an ISO 8601 datetime string into a Python datetime object?

from dateutil import parser

parser.parse('2022-03-21T12:14:28.725Z')

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM