469,282 Members | 1,977 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Question about strftime

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.

Feb 10 '07 #1
2 1277
si***************@gmail.com writes:
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().
Feb 10 '07 #2
En Sat, 10 Feb 2007 17:29:52 -0300, <si***************@gmail.comescribió:
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.

--
Gabriel Genellina

Feb 10 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Richard Shea | last post: by
4 posts views Thread by John Hunter | last post: by
4 posts views Thread by Andy Leszczynski | last post: by
1 post views Thread by Dennis Benzinger | last post: by
3 posts views Thread by HSeganfredo | last post: by
2 posts views Thread by Giovanni Bajo | last post: by
3 posts views Thread by Andrii V. Mishkovskyi | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.