Epoch to DateTime Python

This Python DateTime tutorial will teach you how to convert epoch to DateTime. You can convert epoch to DateTime using the following code:

# Import the datetime module
import datetime

# Epoch
epoch = 1342662623

# Convert the epoch to datetime
date_time = datetime.datetime.fromtimestamp(epoch)

# Display the datetime
print("datetime:", str(date_time))

Output:

datetime: 2012-07-19 06:50:23

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.