Convert date/time to unix timestamp?
M.-A. Lemburg
mal at egenix.com
Tue Feb 10 08:25:56 EST 2009
On 2009-02-10 10:26, Phillip B Oldham wrote:
> Is there a simple way to set a date/time and convert it to a unix
> timestamp? After some googling I found the following:
>
> t = datetime.time(7,0,0)
> starttime = time.mktime(t.timetuple())+1e-6*t.microsecond
>
> That seems like very long-winded. Is there an easier way? I've read
> the docs on the datetime and time modules, but nothing's jumping out
> at me.
>>> from mx.DateTime import DateTime
>>> DateTime(2009,10,2,7,0,0).ticks()
1254459600.0
http://www.egenix.com/products/python/mxBase/mxDateTime/
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Feb 10 2009)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-list
mailing list