Age from DOB one-liner in PHP
There are lots of complex ways to calculate someone’s age from their DOB via PHP, but here’s a simple one:
function getAge($dob) {
return date("Y", time() - strtotime($dob)) - 1970;
}
echo getAge($dob);
Written by Yury Tilis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#