note 74723 deleted from function.strtotime by derick

From: Date: Sun, 15 Jul 2007 12:35:27 +0000
Subject: note 74723 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128545@lists.php.net to get a copy of this message
Note Submitter: admin at partyorpregame dot com ---- I came up with my own function for working around the unix timestamp problem (<5.0 and windows only) when subtracting dates that may be before 1970. This function will take any birthdate and return the age of the person. function findAge($birthdate) { if (!is_numeric($birthdate)) $birthdate = strtotime($birthdate); //converts to unix if not already $sub_yr = 1970; while ($birthdate < 0) { //workaround for dates before 1970 $birthdate = strtotime((date('Y',$birthdate)+10).date('-m-d',$birthdate)); $sub_yr -= 10; } return date('Y',time()-$birthdate)-$sub_yr; }

« previous php.notes (#128545) next »