I am in the eastern time zone but when I run the program, the time output is 4 hours ahead of me.
I don't think I need to specify my time zone. When I run the program on python on my PC, I get my local time.
To make this work on repl.it, you should probably specify the timezone. By default, the timezone is Coordinated Universal Time, or UTC. Using
datetime.now() gets the local time, but when using repl.it, the code is processed on their servers and sent back to you. I would imagine they would use UTC rather than their timezone. Here's a timezone example:
# Imports from datetime import datetime from pytz import timezone # Set timezone tz = timezone("US/Eastern") # Date with timezone date = datetime.now(tz) # Formatting format_date = date.strftime("%d/%m/%Y %H:%M:%S") print(format_date)