
Epoch is time representation standard that is used on Unix timestamp which every digit represents every second happens from January 1st, 1970 until today. Epoch time contain 10 digit number and represented every time zone with added 3600 seconds. We will sometime have to work with this Epoch time when we handle data in logs and databases.
1. What you need to do before do this tutorial?
Have Python programming language installed on your PC.
Make sure Python is included in path Command Line
💡 Tips
If you don't want install Python on your computer, you can use Google Colaboratory and code in your browser.
2. Convert Epoch to Datetime in Python
Import Datetime Library
First we need to import datetime library in Python so we can use datetime class with all the function in it.
📝 Code
TODO : Import datetime libraryfrom datetime import datetimeConvert using fromtimestamp function
📝 Code
TODO : Convert Epoch to DatetimeepochTime = 1676106378currentTime = datetime.fromtimestamp( epochTime )print('1. Current Epoch to Datetime : ',currentTime)
The currentTime will return date with datetime data type and that's how you convert Epoch to Datetime in Python.
