| | |
Age Calculation
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 49
Reputation:
Solved Threads: 0
Hi guys, i have been trawling around looking for a decent and simple way of working out an age from a birthday.
The way i'm working is a date of birth is added to a database then when pulled we echo the actual age and not the d.o.b.
It's probably quite simple but i can't seem to figure it out, Also there may not be an actual day eg 06/2009 instead of 13/06/2009 if you see my meaning.
Any direction would be great!
Thanks again...
The way i'm working is a date of birth is added to a database then when pulled we echo the actual age and not the d.o.b.
It's probably quite simple but i can't seem to figure it out, Also there may not be an actual day eg 06/2009 instead of 13/06/2009 if you see my meaning.
Any direction would be great!
Thanks again...
•
•
Join Date: Aug 2009
Posts: 49
Reputation:
Solved Threads: 8
1
#2 Nov 3rd, 2009
How about converting the date string into a UNIX timestamp, then subtracting that stamp from today's stamp?
Something like:
Something like:
PHP Syntax (Toggle Plain Text)
$b_day = strtotime("1/1/1970"); // UNIX time for birthday $today = strtotime(date("m/d/Y")); $age = date("your formatting string here", $today - $b_day));
-1
#3 Nov 3rd, 2009
Should be clear from the next row but if not:
@EF - sorry for jumping in.
PHP Syntax (Toggle Plain Text)
b_day = strtotime("1/1/1970") //is also in m/d/Y (US) format
@EF - sorry for jumping in.
If you don't reply to your own thread or you can't find the solved link - you're off my Christmas list - permanently! Bah humbug!
![]() |
Similar Threads
- VB6 age calculator (Visual Basic 4 / 5 / 6)
- Age counter - Any other way? (Python)
- New to C program code to calculate age (C)
- News Story: Old age open source initiative (Mac Rumors and Reports)
- Please check this code (Java)
- Calculating age (PHP)
- Your exact age (C++)
- I've made some code to reject age ranges, but cant get it working (Java)
Other Threads in the PHP Forum
- Previous Thread: How to Update a record in a database
- Next Thread: if isset ==
Views: 295 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






