note 74723 added to function.strtotime

From: Date: Wed, 25 Apr 2007 07:09:28 +0000
Subject: note 74723 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-125849@lists.php.net to get a copy of this message
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; } ---- Server IP: 69.147.83.197 Probable Submitter: 72.188.224.94 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/74723 Del: integrated -- https://master.php.net/note/delete/74723/integrated Del: useless -- https://master.php.net/note/delete/74723/useless Del: bad code -- https://master.php.net/note/delete/74723/bad+code Del: spam -- https://master.php.net/note/delete/74723/spam Del: non-english -- https://master.php.net/note/delete/74723/non-english Del: in docs -- https://master.php.net/note/delete/74723/in+docs Del: other reasons-- https://master.php.net/note/delete/74723 Reject -- https://master.php.net/note/reject/74723 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125849) next »