converting epoch time to string (and vice versa)
Amit Khemka
khemkaamit at gmail.com
Tue Mar 13 01:52:08 EDT 2007
On 3/13/07, Astan Chee <stanc at al.com.au> wrote:
> Hi,
> I have a string in this format "DD/MM/YYY" for example:
> tdate = "18/01/1990"
> and Im trying to convert this to epoch time, can anyone help?
import calendar
t = map(int,tdate.split('/'))
epochs = calendar.timegm((t[2], t[1], t[0], 0, 0, 0))
> Im also trying to convert that epoch time to the string format
> previously. Can anyone help this one too?
import time
time.ctime(epochs)
cheers,
amit.
--
----
Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
More information about the Python-list
mailing list