Python: Convert a given time in seconds since the epoch

Python Operating System Services: Exercise-23 with Solution

Write a Python program to convert a given time in seconds since the epoch to a string representing local time.

Sample Solution:

Python Code :

import time

Sample Output:

Tue Jan 21 08:18:33 2020
Thu Jun 30 18:36:29 1977

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program that can suspend execution of a given script a given number of seconds.
Next: Write a Python program to print simple format of time, full names and the representation format and preferred date time format.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

Python: Tips of the Day

Python: Unpack a Tuple

>>> items = (0, 'b', 'one', 10,  11, 'zero')
>>> a, b, c, d, e, f = items
>>> print(f)
>>> a, *b, c = items
>>> print(b)
['b', 'one', 10, 11]
>>> *_, a, b = items
>>> print(a)