Amit Khemka gmail.com> writes:
>
> Check out timegm function in calendar module. The following function
> converts "mm/dd/" formats into epoch value, you can hack it for
> your date formats.
>
> def convertToEpoch(date):
> tup = map(int,date.split('/'))
> l = (tup[2], tup[0], tup[1], 0, 0, 0)
> epochs = calendar.timegm(l)
> return (int(epochs))
Thanks for your suggestion... For me this was the Solutions:
# convert '-mm-dd hh:mm:ss' to epoch
def toEpoch(timestamp):
split = str(timestamp).split(' ')
tdate = map(int,split[0].split('-'))
ttime = map(int,split[1].split(':'))
tcode = (tdate[0], tdate[1], tdate[2], ttime[0], ttime[1], ttime[2])
epoch = timegm(tcode)
return (int(epoch))
Stefan.
--
http://mail.python.org/mailman/listinfo/python-list