'Date iso format python

I have this date form in python that I am writing on an api: 2022-06-01T10:36:56.000Z How can I turn this into a second? Thanks for your comments

I would like to use the seconds I have to do addition division and then go back to day/date/hour format

I can't find any content on the internet



Solution 1:[1]

Python cannot handle all type of iso formatted date strings. So you can use isodate library or remove .000Z from the string parsing.

You can be more clear on seconds though, is it total seconds elapsed from 1970, Jan 1 or seconds part in the date ?

k = datetime.fromisoformat("2022-06-01T10:36:56.000Z".replace(".000Z", ""))
k.timestamp()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1