Page 1 of 1
Calling mktime before 1/1/1960
Posted: Thu May 27, 2004 7:34 pm
by techlinks
Hi again:
I need to calculate the number of minutes between the current time and
January 1, 1601. Can someone suggest an optimal way to do this in PHP? I can't do a mktime on the date 1/1/1601 because it complains it can't go back further than 1/1/1970. Thanks in advance
Posted: Thu May 27, 2004 7:40 pm
by kettle_drum
mins in hour = 60
mins in day = 60*24
mins in year = 60*24*365
mins in leap year = 60*24*366
years since 1601 = 403
leap years = 100
days since 1 jan = ...
Etc, and just work your way back. Im sure you can make a function so it will tell you for any date you imput, its just a process of working it out.
Posted: Thu May 27, 2004 7:57 pm
by techlinks
thanks for the prompt response. this may be a silly question but how did you compute:
mins in leap year = 60*24*366
and
leap years = 100
I don't quite understand.
Thanks
Posted: Fri May 28, 2004 2:41 am
by crookedgoomba
divide the number of years since 1601 by 4... considering there are leap years every 4 years
Posted: Fri May 28, 2004 9:54 am
by pickle
crookedgoomba wrote:divide the number of years since 1601 by 4... considering there are leap years every 4 years
Ya, leap years every 4 years, except when the year is divisible by 100, except when the year is divisible by 400 (then it's a leap year as well).
Posted: Fri May 28, 2004 9:59 am
by magicrobotmonkey
or you could just use mins in year = 60*24*365.25 and leave it at that (i think)
Posted: Fri May 28, 2004 10:08 am
by Grim...
Sorry to get technical (and I'm sure this is over the top for what you want) but if you want to be really accurate you have to take into account leap
seconds as well.
Leap seconds occur because the effect of the tides on the Earth's rotation slows it down, putting our day/night timings out slightly.
There is much more information
here.
Posted: Fri May 28, 2004 10:36 am
by magicrobotmonkey
awesome! i heard on npr that they think the earths spin is slowing down
Posted: Fri May 28, 2004 11:16 am
by kettle_drum
Nice, i never knew about leap seconds. Thanks for the info grim...
Posted: Fri May 28, 2004 11:17 am
by Grim...
It's kind of my job to know about time - I work for a Time & Attendance company, and our software has to be very accurate.