Skip to content
Sign upLog in
← Back to Community
I am in the eastern time zone but when I run the program, the time output is 4 hours ahead of me.
Profile icon
EthanJohnson11

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.

Voters
Profile icon
Oliver-Miller-bot
Profile icon
AA27RON
Profile icon
DanielCothran
Profile icon
KhushiKANODIA
Profile icon
DominicHuieWhit
Profile icon
EthanJohnson11
Comments
hotnewtop
Profile icon
Roar123

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)