For the special date of January 1, 1970 there are multiple options.
For any other starting date you need to get the difference between the two dates in seconds. Subtracting two dates gives a timedelta object, which as of Python 2.7 has a total_seconds() function.
The starting date is usually specified in UTC, so for proper results the datetime you feed into this formula should be in UTC as well. If your datetime isn't in UTC already, you'll need to convert it before you use it, or attach a tzinfo class that has the proper offset.
As noted in the comments, if you have a tzinfo attached to your datetime then you'll need one on the starting date as well or the subtraction will fail; for the example above I would add tzinfo=pytz.utc if using Python 2 or tzinfo=timezone.utc if using Python 3.
Python now warns me: "TypeError: can't subtract offset-naive and offset-aware datetimes" What's the best solution to fix that?
Consider using: datetime.datetime.utcfromtimestamp(0) I've used this to get the 'epoch' easily. Note that epoch is not always the same on all systems.
@D.A.: Python does not support non-POSIX epochs. All systems where python works use the same Epoch: 1970-01-01 00:00:00 UTC
@felice, there's an answer to this question that says the same, you should give it an upvote. Was there a point to your comment?