|
a birthday to age php script
|
View this Thread in Original format
| Boomer187 |
I am finishing up this questionnaire for a research project we have going and I wanted to get peoples age by their birthday. I didn't find any working scripts using google but ended up solving the problem. And this seemed very easy to do in my mind, but I couldn't get it to work for a while. So I modified some existing script that didn't quite work. It had a problem with people who have not had their birthday yet, it counted them as a year older.
I didn't even think to ask help here when I was stumped. So instead I will post up the ugly, non noted, horribly written code I ended up with. Modify it if you want.
PHP:
these php colors suck :-/ |
|
|
| alefort |
Hmmm...gotta say, that is one NASTY looking function. I wrote a function like this ages ago, and it was simply one line. Here it is:
PHP:
This Outputs: 24.27 Years old for me. |
|
|
| Boomer187 |
thanks, I specialize in nasty scripts :p
I knew there are probably a million easier, nicer, more handy ones out there. But for some reason I can never think of one of them.
One of my attempts used something similar with mktime, but somehow it said i was 37 years old no matter what day I was born on. Obviously I messed up something besides the formulas. |
|
|
|
|