Easy to use time-stamps in Python
Posted
by Morlock
on Stack Overflow
See other posts from Stack Overflow
or by Morlock
Published on 2010-01-24T15:01:42Z
Indexed on
2010/03/09
0:51 UTC
Read the original article
Hit count: 337
I'm working on a journal-type application in Python. The application basically permits the user write entries in the journal and adds a time-stamp for later querying the journal.
As of now, I use the time.ctime()
function to generate time-stamps that are visually friendly. The journal entries thus look like:
Thu Jan 21 19:59:47 2010 Did something
Thu Jan 21 20:01:07 2010 Did something else
Now, I would like to be able to use these time-stamps to do some searching/querying. I need to be able to search, for example, for "2010", or "feb 2010", or "23 feb 2010".
My questions are:
1) What time module(s) should I use: time
vs datetime
?
2) What would be an appropriate way of creating and using the time-stamp objects?
Many thanks!
© Stack Overflow or respective owner