note 51708 added to function.date

From: Date: Fri, 08 Apr 2005 05:49:55 +0000
Subject: note 51708 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-87688@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51708 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51708&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51708&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51708&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51708&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51708&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51708&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87688) next »