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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top