views:

180

answers:

4

I'm trying to write a javascript function that calculates the time since Oct 11th, 1910 so I can throw it into a timer for a project I'm working on. I get that javascript's milliseconds works from epoc, but I don't and can't find a way to get the milliseconds since a date earlier than 01.01.1970

Does anyone have any loose code that can do the above that they may be willing to share?

A: 

I suppose one way to do it yourself is to figure out the number of milliseconds from 01.0.1.1970 and 11 October 1910, and add that to the number of milliseconds from 1970 till now.

Other than that, I have no idea.

ZachS
A: 

Look at the source of this page; not sure how accurate it is but it might help you:

http://www.timeanddate.com/date/duration.html

How accurate do you have to be? Within minutes, hours, days?

I82Much
A: 

Try this:

var yeOldeTimes = new Date();
yeOldeTimes.setFullYear(1910, 9, 11);

var myNewDate = new Date();
alert("Milliseconds since Ye Olde Times: " + (myNewDate - yeOldeTimes));
nickf
A: 
var oldGoodTimes = new Date(1910, 9, 11); // January = 0
var actualDate = new Date();
return (actualDate.getTime() - oldGoodTimes.getTime());
Rodrigo