Question about strftime

S

silverburgh.meryl

Hi,

I have question about strftime. I am trying to print the current time
in this format:

date = strftime("%Y%m%d_%H%M%S", gmtime())
print date

I run the script at 2:18 pm, but I get this: 20070210_201837

Can you please tell me why I get '20'? instead of '14' (which is 2:00
pm)?

Thank you.
 
P

Paul Rubin

date = strftime("%Y%m%d_%H%M%S", gmtime())
print date

I run the script at 2:18 pm, but I get this: 20070210_201837
Can you please tell me why I get '20'? instead of '14' (which is 2:00
pm)?

Wrong time zone? Maybe you want localtime() instead of gmtime().
 
G

Gabriel Genellina

I have question about strftime. I am trying to print the current time
in this format:

date = strftime("%Y%m%d_%H%M%S", gmtime())
print date

I run the script at 2:18 pm, but I get this: 20070210_201837

Can you please tell me why I get '20'? instead of '14' (which is 2:00
pm)?

gmtime() returns the time in UTC, not local time, and your computer thinks
you're in Mexico, central USA or Canada.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Newbie: strftime object error message 3
datetime question 57
utcnow 0
need to print seconds from the epoch including the millisecond 35
extending strftime 2
strftime() behaviour 3
Help with code 0
datetime issue 126

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top