note 27474 deleted from function.mktime by sniper
| From: | sniper@php.net | Date: | Tue, 04 Nov 2003 13:11:20 +0000 |
| Subject: | note 27474 deleted from function.mktime by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59878@lists.php.net to get a copy of this message | ||
Note Submitter: wes@WebCodingShopDotSomething
----
OK, so in trying to get a date of birth on 4-10-1955 to end up in a Windows type date, 20189 (num
days since 1900), I need to figure out how to make mktime() go back to 1900 to get the number of
days to this goobers DOB. Well, as indicated by everyone, you cannot get mktime() to go back that
far. So, the number of days from 1-1-1900 to 1-1-1970 is 25,550 + 18 leap years = 25,568. So, to get
the number of days from 1-1-1900 to 4-10-1955, do this:
$numDaysSince1900 = ceil(mktime(0,0,0,4,10,1955)/(60*60*24))+25568;
So, we got the number of seconds from 4-10-1955 until 1-1-1970 (negative), divide by the number of
seconds*minutes*hours to get it into days, then add this number to the number of days from
1955-1970. It was a decimal for some reason that seemed to work out correctly if I rounded
up:ceil().
Don't even ask how long it took me to do this. I'm not sure I want to know if I am a
moron, and there is an easier way to do it.