convert from date string to epoch
Amit Khemka
khemkaamit at gmail.com
Sat Dec 16 01:04:12 EST 2006
More information about the Python-list mailing list
Sat Dec 16 01:04:12 EST 2006
- Previous message (by thread): convert from date string to epoch
- Next message (by thread): convert from date string to epoch
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12/16/06, Stefan Antonelli <stefan.antonelli at operun.de> wrote: > Hi, > > i have to convert several timestamps. The given format, eg "yyyy-mm-dd hh:mm:ss" > has to be converted to an epoch string. Is there any proper way to do this? > > If not, i have to split the given string and resolve this by a calculation? > > Thanks for help. > > Stefan. Check out timegm function in calendar module. The following function converts "mm/dd/yyyy" 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)) HTH, 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.
- Previous message (by thread): convert from date string to epoch
- Next message (by thread): convert from date string to epoch
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list