I have a date in the format of YYYY-MM-DD, how can I figure out the age of the person according to that date, which is their birthdate. Is there a easy way to do this?

    Well, you'd explode that into $month, $day, and $year, then find the current month year and day with date...

    Then you'd have the values needed to calculate it.

      Are you using user-inputted dates or are you pulling from a database? If so, you can use mySQL to perform this:
      $query = "SELECT birthday,((TO_DAYS(todays_date)-TO_DAYS(birthday))/365.25) AS age FROM table WHERE user_id = $user_id ";

        I figured this out

        SELECT birth, ( ( TO_DAYS( NOW( ) ) - TO_DAYS( birth ) ) / 365.25 ) AS age FROM roster WHERE id = '2'

        it returns 29.9001 I am lame and cant figure out how to just return 29

          Ok I use this code...

          	$age = number_format($age, 0, '.', '');

          But as soon as I go down to 0 decimal points it rounds up? I dont want it to round up.

            Wow I didnt even think to use that function....nice.

            Oh about the original post, if the birthday is before 1970 the persons info does not show....how do I get birthdays to show before 1970?

              Write a Reply...