datetime - Easy to use time-stamps in Python -


I'm working on a journal-type application in Python. The application originally allows entry entries in the user magazine and later adds time-stamp to the journal for inquiries.

So far, I use the time.ctime () function to generate time-stamps that are favorable in view, thus journal entries appear in this way :

  Thursday 21 January 19:59:47 2010 Something happened 21 January 2010 20:01:07 What else was  

Now, I have some I would like to be able to use these timetables for searching / inquiry. For example, "2010", or "Fab 2010", or "23 February 2010" need to be able to search me.

My questions are:

1) What time module should be used: time versus datetime ?

2) What is the proper way to create and use time-stamp objects?

Many thanks!

Option 1: Do not change anything. Use to parse your timestamp.

Option 2: Change to Date Time . You can format the timestamp in the same way, and use it to parse them.

It does not matter too much, because the code will be the same. Research will include months, days or years or some such matches, for this, use time topless or datetime.datetime objects or, compare the search time limits Is included; For this, use time in seconds or use the date time objects, both of which will work and - for this - they will be similar in complexity.

Calculating the date (90 days in the future, 3 months in the past, etc.) is a strong suit date .

In general, you will often be happy with datetime because it does more work and does not include simple double time and time between switching between Tupal times.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -