By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,871 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,871 IT Pros & Developers. It's quick & easy.

convert from date string to epoch

P: n/a
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.

Dec 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Stefan Antonelli 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.
What is 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?
Is that a question or a statement?

Dec 16 '06 #2

P: n/a
Stefan Antonelli 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.
I saw some code on the net. ASPB I think. I whacked a few more lines
to be an example.

#!/usr/bin/env python
import httplib
import time

ht = httplib.HTTP('www.python.org')
fich='/index.html'
print fich,
ht.putrequest('GET', fich)
ht.endheaders()
errcode, errmsg, headers = ht.getreply()
print headers.dict
print headers.dict['server']
textoFecha=headers.dict['date']
print textoFecha
fecha = time.strptime(textoFecha,'%a, %d %b %Y %H:%M:%S %Z')
print fecha
print time.asctime(fecha)
print time.mktime(fecha)
print "==="
fecha = time.strptime('2006-12-15 19:42','%Y-%m-%d %H:%M')
print fecha
print time.asctime(fecha)
print time.mktime(fecha)
Dec 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.