Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-24-2004, 11:44 AM   PM User | #1
MatesOnline
New Coder

 
Join Date: Jul 2004
Location: Leamington, UK
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
MatesOnline is an unknown quantity at this point
Date calculation

Hi everyone

ok for most of you this will be very easy lol

i have a registration form on my site and i have 3 drop down menu's
day , mon , year each containing 2 digit numbers


what i would like to do .. is when they submit the form
the page will automatically determin their age based on the selections from day , mon , year

sounds easy huh? lol

any help will be appreciated
MatesOnline is offline   Reply With Quote
Old 09-24-2004, 12:54 PM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
indeed very easy. but instead of spending time reinventing this sort of things, i always just run a search at www.php.net and there are plenty of premade scripts like this one
PHP Code:
/*chris dot shepherd at gmail dot com
27-Aug-2004 05:59 
A nice way to calc age seeing that mktime only goes back until 1970 is to use the date function like this... */

<?php 
//Find the difference in year, month, and day 
$yeardiff date("Y") - $dobyear
$monthdiff date("m") - $dobmonth
$daydiff date("j") - $dobday

/* 
 * if month or day is negative we have yet to reach it so 
 * we need to subtract a year seeing we haven't 
 * reached our birthday yet, else yeardiff is correct 
 */ 

if ($monthdiff <= && $daydiff 0) { 
   
$age $yeardiff 1
} else { 
   
$age $yeardiff


echo 
$age
?>
on http://www.php.net/date
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 09-24-2004, 12:58 PM   PM User | #3
MatesOnline
New Coder

 
Join Date: Jul 2004
Location: Leamington, UK
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
MatesOnline is an unknown quantity at this point
ahh

perfect.

Thanks
MatesOnline is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:08 AM.


Advertisement
Log in to turn off these ads.