Convert int to DateTime Python

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

# Import the datetime module
import datetime

# Integer
integer = 1670662600

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

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

Output:

datetime: 2022-12-10 13:56:40

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.