How to format elapsed time from seconds to hours, minutes, seconds and milliseconds in Python? January 29, 2023 by Tarik You could exploit timedelta: >>> from datetime import timedelta >>> str(timedelta(seconds=elapsed)) '0:00:00.233000'