1

I'm working with data whose time format is in datetime and looks like the following 'modified': '2016-08-24T12:52:39.780790+00:00'. I'm looking to retrieve the modification time of a file on my O.S which is returned in this format 1606414504.705609 and convert it to match the format I've shown above. What's the best way to do this?

Blank
  • 155
  • 4
  • 16
  • 1
    from the datetime module, import datetime and timezone, then `datetime.fromtimestamp(1606414504.705609, tz=timezone.utc).isoformat()` – FObersteiner Nov 30 '20 at 15:32
  • 1
    Does this answer your question? [Converting unix timestamp string to readable date](https://stackoverflow.com/questions/3682748/converting-unix-timestamp-string-to-readable-date) – FObersteiner Nov 30 '20 at 15:34
  • 1
    btw. the *format* is specified [here: ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) – FObersteiner Nov 30 '20 at 15:35
  • @MrFuppes Hi, yes this does answer my question! Thank you! Would you like to put your answer down as the main answer so I can select it as the solution? Your first comment answered my question, not the second – Blank Nov 30 '20 at 17:11
  • 1
    I'm glad if I could help you, no need for an extra answer here. I've added a more [concise answer](https://stackoverflow.com/a/65076703/10197418) to the linked question (comment #2). – FObersteiner Nov 30 '20 at 17:18

0 Answers0