Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: converting datetime with tzinfo to unix timestamp

2 views
Skip to first unread message

Gabriel Genellina

unread,
Mar 15, 2010, 11:52:43 PM3/15/10
to pytho...@python.org
En Fri, 12 Mar 2010 20:15:55 -0300, Michael Torrie <tor...@gmail.com>
escribió:

> On Python 2.5 here.
>
> I've searched and searched but I can't find any way to convert a
> datetime object that includes a timezone (tzinfo) to a unix timestamp.
> Folks on the net say to simply use the timetuple() method of the object
> and feed that to time.mktime(). But that just doesn't seem to work for
> me. At least if my understanding that the unix timestamp is always UTC.

Try time.mktime(datetimeobject.utctimetuple()) instead.

--
Gabriel Genellina

0 new messages