[PHP-DB] difference between two dates
Hello, In my application I am accepting Day, Month and Year from a Select List. What I want to do is calculate the age of the person based on the above selection. $cboDD is the day variable $cboMM is the month variable $cboYY is the year variable I tried this : $dobtimestamp = mktime(0,0,0,$cboMM,$cboDD,$cboYY); $todaytimestamp = time(); $txtAge = ($todaytimestamp - $dobtimestamp)/86400; It does not give me the expected output. Can anybody suggest something ? Thanks in advance. Peace -- Rajesh * [EMAIL PROTECTED] * http://www.symonds.net/~rajesh/ Powered By : Debian GNU/Linux 3.0 (Woody) - [Kernel 2.4.18(ext3),Mutt 1.5.1i] What we anticipate seldom occurs; what we least expect generally happens. -- Bengamin Disraeli -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] difference between two dates
In my application I am accepting Day, Month and Year from a Select List. What I want to do is calculate the age of the person based on the above selection. $cboDD is the day variable $cboMM is the month variable $cboYY is the year variable I tried this : $dobtimestamp = mktime(0,0,0,$cboMM,$cboDD,$cboYY); $todaytimestamp = time(); $txtAge = ($todaytimestamp - $dobtimestamp)/86400; It does not give me the expected output. Can anybody suggest something ? Keep your mktime() as it is, that's correct. Then use something like this to calculate the age: $age = date('Y',$now) - date('Y',$dob) - ((date('z',$now)=date('z',$dob)) ? 0 : 1); where $dob and $now are the appropriate unix timestamps that you've already got calculated with mktime() and time(). ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] difference between two dates
On Sun, Jan 19, 2003 at 09:34:02AM -0500, John W. Holmes wrote: I tried this : $dobtimestamp = mktime(0,0,0,$cboMM,$cboDD,$cboYY); $todaytimestamp = time(); $txtAge = ($todaytimestamp - $dobtimestamp)/86400; It does not give me the expected output. Can anybody suggest something ? Keep your mktime() as it is, that's correct. Then use something like this to calculate the age: $age = date('Y',$now) - date('Y',$dob) - ((date('z',$now)=date('z',$dob)) ? 0 : 1); where $dob and $now are the appropriate unix timestamps that you've already got calculated with mktime() and time(). Thanks a lot. Peace -- Rajesh : [ GNU/Linux One Stanza Tip (LOST) ]### Sub : ext3 file system LOST #034 To implement ext3 filesystem have a good look here (Cool) : http://www.uow.edu.au/~andrewm/linux/ext3/ext3-usage.html [EMAIL PROTECTED]### : -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php