Python: Find out what the epoch is on a given platform
Python Datetime: Exercise-55 with Solution
The epoch is the point where time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). Write a Python program to find out what the epoch is on a given platform. Convert a given time in seconds since the epoch.
Sample Solution:
Python Code:
import time
print("\nEpoch on a given platform:")
print(time.gmtime(0))
print("\nTime in seconds since the epoch:")
print(time.gmtime(36000))
Sample Output:
Epoch on a given platform: time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0) Time in seconds since the epoch: time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=10, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)
Flowchart:

Python Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Python program to set the default timezone used by all date/time functions.
Next: Write a Python program to get time values with components using local time and gmtime
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join