![]() |
Converting timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Converting timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 (/thread-39829.html) |
Converting timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 - bigcat - Apr-19-2023 Hi, how to convert a timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 ? Thanks in advance, Regards, Den. RE: Converting timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 - bigcat - Apr-19-2023 Solved. from datetime import datetime date = datetime.strptime("$1", "%Y-%m-%dT%H:%M:%S.%f%z") print (date.strftime("%Y%m%d%H%M%S")) RE: Converting timestamp like 2023-04-18T20:00:10.000Z to 20230418200010 - DeaD_EyE - Apr-20-2023 It's ISO8601 and the method datetime.fromiso interprets this standard.Docs: https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat timestamp = datetime.datetime.fromisoformat("2023-04-18T20:00:10.000Z") |