convert from date string to epoch

S

Stefan Antonelli

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.
 
J

John Machin

Stefan said:
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?
 
P

Paul Watson

Stefan said:
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)
 

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

No members online now.

Forum statistics

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

Latest Threads

Top