I want to be able to get two time stamps and compare if the second (later taken) one is less than 59 minutes away from the first one. Following this thread Compare two dates with JavaScript the date object may do the job.
But first thing I am not happy with is that it takes the time from my system. Is it possible to get the time from some public server or something? Cause there always is a chance that the system clock gets manipulated within the time stamps, so that would be too unreliable. Some outside source would be great.
Then I am not too sure how to get the difference between 2 times (using 2 date objects). I The times could be something like 3:59 and 6:12, so just comparing minutes would give the wrong idea. Thus we should consider hours too. But then there the issue with the modulo 24. Day 3 23:59 and day 4 0:33 wouldn't produce proper results either.
So including days too. then the modulo 30 thing, even though that on top changes month for month. So month and year need to be included as well.
Hence, we would need the whole date, everything from current year to second (because second would be nice too, for precision) and comparing them would require tons of if clauses for year, month, etc.
Do the date objects have some predefined date comparison function that actually keeps all these things in mind (haven't even mentioned leap years yet, have I)?
The time would be very important cause exactly at the 59 minutes mark (+-max 5 seconds wouldn't matter but getting close to 60 is forbidden) a certain function would have to be used that without fail closes a website. The script opens website at mark 0 min, does some stuff, rinse and repeat style, and closes the page at the 59 min mark.
Checking the time like every few seconds would be smart.
Any good ideas how to implement such a time comparison that doesn't take too more computer power yet is efficient as in new month starting and stuff doesn't mess it up?