Jump to content

[SOLVED] age in years and months


R0bb0b

Recommended Posts

I can calculate age in years very easily but I also need months too.  For example 39yrs and 5mos old.  I would rack my own head against the wall for a while but unfortunately I am currently pressed for time and would like to know if anybody can point out a function that will do this.  Much appreciated.

Link to comment
Share on other sites

Actually decided to use this function:

http://us3.php.net/manual/it/function.mktime.php#86086

which returns an array of months, days, and a year in decimal format.

 

I'm also using this line to take into account leapyear:

<?php $leapyear = date('L', mktime(0, 0, 0, 1, 1, date("Y"))) ? 366 : 365; ?>

 

Thought about the different values for months in a year and figuring out which month to start counting from and etc... etc... and said :P

 

I just divided days by 30.4 which is as accurate as I need to be for this project.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.