Celebrity Age Calculator

Those pesky celebrities. Always being different ages. Always maybe being older than they were in the article you copied. . .

It’s enough to make you want to write a function that will calculate their age for you. Good thing each person’s birthday doesn’t change.

$celebAge = floor((time() - strtotime('1970-01-01')) / 31557600);

This calculation takes a date. The day you want to start counting from. It calculates how many years have passed based on some math about what the time is now and how many seconds are in a normal year.

Arguably there is a better number than 31557600 seconds in a year. On account of leap years, and sometimes that one leap second. . . That difference is negligible.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.