I need to convert a zope 2 DateTime object into a Python datetime object. What is the best way to do that? Thanks, Erika
Asked
Active
Viewed 1,492 times
3 Answers
11
Newer DateTime implementations (2.11 and up) have a asdatetime
method that returns a python datetime.datetime instance:
modernthingy = zopethingy.asdatetime()

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343
7
modernthingy = datetime.datetime.fromtimestamp(zopethingy.timeTime())
The datetime
instance is timezone-naive; if you need to support timezones (as Zope2's DateTime
does), I recommend third-party extension package pytz.

Alex Martelli
- 854,459
- 170
- 1,222
- 1,395