Wrong date/time


#1

It shows 11/11/2016 06:43

It's actually 10/11/2016 22:06 right now

Don't know if it should show what time is it now, but it surely should show the correct date. What may be going wrong?? I think it's not the code, but i don'y know, maybe???


#2

Pretty interesting problem. Try to run the code again. If it doesn't work, send here the code.


#3

I tried several times and still didn't work, so here's the code:

from datetime import datetime
now = datetime.now()
print now

And this one also has a problem:

from datetime import datetime

now = datetime.now()

print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)

Now I noticed the minutes and seconds are correct (and, right now, the date is, too), but the clock in the code is two hours ahead of the one in my computer, so it seems to be the timezone (I live in GMT -3). Any idea of how can I adjust the clock to my timezone?


#4

I have exactly the same code, and now I saw too, that the datetime isn't right.


#5

Well first off, I don't believe you are meant to change the time at all to your current time. There is no way that the time could be right for everyone therefore one time zone or time setting has been chosen behind the scenes. You really shouldn't worry about the time but worry about fixing the code properly! First, does your code have an actual error or are you worried about the time not being right? As stated before, the time is not going to match your current time more than likely. If you do have an error with the actual code and not time then just post it in a reply.


#6

Yeah, the code is correct, so i guess that's it. I was just concerned about
the time not matching my time zone. It seems time/date is set to match GMT.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.