note 51708 deleted from function.date by derick

From: Date: Sun, 15 Jan 2006 12:46:19 +0000
Subject: note 51708 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-101839@lists.php.net to get a copy of this message
Note Submitter: hossy at hossy dot com ---- This note is in reply to bhaveshsurani at gmail dot com: There is functionality to calculate the difference between two dates and get an array. I did this function to calculate my age: function getmyage() { $bday = gmmktime(14,29,0,9,23,1981)+(60*60*5); //The '+mktime(0,0,0,1,1,1970)' will add the local server's GMT offset to the time. //This will convert the server's current local time to GMT. //This is needed because $bday is calculated for a specific time zone (Central w/ DST: GMT-05:00) $dif = (time() + mktime(0,0,0,1,1,1970)) - $bday; $dif = getdate($dif); //Since mktime calculates the time from the Unix Epoch (January 1 1970 00:00:00 GMT), subtract 1970 from the year value. return ($dif['year'] - 1970); } Hope this helps.

« previous php.notes (#101839) next »