need a little help with time

N

nephish

Hey there.
i have a time string (created with strftime) then read from a file,
i am having some trouble understanding how to get the difference
between times.
i know i can structime(timestring) and get a time value, but i dont
know how to manipulate it.

basically, if i have string 2005-08-24 09:25:58
and another string 2005-08-24 09:28:58

how can i tell how many minutes, hours, seconds, days, months etc..
have passed between the first string and the second ?

or, if there is a good tutorial on this kind of thing, please post a
url.

thanks

shawn
 
D

Diez B. Roggisch

Hey there.
i have a time string (created with strftime) then read from a file,
i am having some trouble understanding how to get the difference
between times.
i know i can structime(timestring) and get a time value, but i dont
know how to manipulate it.

basically, if i have string 2005-08-24 09:25:58
and another string 2005-08-24 09:28:58

how can i tell how many minutes, hours, seconds, days, months etc..
have passed between the first string and the second ?

or, if there is a good tutorial on this kind of thing, please post a
url.

Look at the module datetime.

Diez
 
E

Eddie Corns

Hey there.
i have a time string (created with strftime) then read from a file,
i am having some trouble understanding how to get the difference
between times.
i know i can structime(timestring) and get a time value, but i dont
know how to manipulate it.
basically, if i have string 2005-08-24 09:25:58
and another string 2005-08-24 09:28:58
how can i tell how many minutes, hours, seconds, days, months etc..
have passed between the first string and the second ?
or, if there is a good tutorial on this kind of thing, please post a
url.

Either the datetime module or mxDateTime from
http://www.egenix.com/files/python/mxDateTime.html
which is more extensive.
 
N

nephish

the mxDateTime thing should be great, i have to pass this stuff back
and forth with MySQL DateTime fields,
thanks a lot !
 
R

Randy Bush

i am doing disgusting looking junk based on calendar. example

now = calendar.timegm(time.gmtime())
aWeek = 7*24*60*60
print time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(now + aWeek))

randy
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top