# Problem with Year < 1900

• Apr 29, 2007, 08:36
zeeshanhashmi
Problem with Year < 1900
Hi

I have a situation, where we input ages. The application is for older people. therefore, it might happen that some one is older and his date of birthe is 1899 or 1892 etc. He will definately a lucky guy having this much long age. But what i ahve come to know that PHP has a limitation of backward timpstamp. That is t cant go beyond 1900.

I am using mktime() function, so is there any way out to this ?

Regards
• Apr 29, 2007, 08:52
Dashman
Hi,

Why do you need to use a timestamp for age input? You could just use a field type of "int" or "tinyint". How is this field going to be used?

D
• Apr 29, 2007, 08:53
kyberfabrikken
You shouldn't use a timestamp for something like that. A date is more complex. Since you probably use a database for storing the dates anyway, you can also use the database's date handling functions. That is -- Store dates in the database as type DATETIME, and do all date-based algebra in the database.
• Apr 29, 2007, 09:48
zeeshanhashmi
actually the situatino is to calculate the EXACT date. That include a policy that if the next date of birthe is within 240 days then Age = Age + 1 other wise age = age. Moreover, there are 4 ages and we have to check which one is the YOUNGER and which one is the older. And we need to calculate the Exact age. Not 2007 - Year of birther. Like my Birthday is 20/05/1979, then 2007-1979 = 28 but actually i m not 28 years now. there are still 20 days to go. Another example is like suppose your birthe day is 31-12-1980 then 2007 - 1980 = 27 but u are not 27 at this point. There are still 8 months. so your age is 26 these sort of calculation i have to made and then i have to check the younger and older also.

• Apr 29, 2007, 09:51
Dashman
OK, I get ya ... I suppose I would go with kyberfabrikken's advice
• Apr 29, 2007, 09:55
zeeshanhashmi
can u people gudie me how to do my tasks through that u 've suggested ?
• Apr 29, 2007, 10:54
kyberfabrikken
To calculate the difference in years, between two dates:
Code:

`SELECT YEAR("2007-04-29") - YEAR("1979-05-20") - (RIGHT("2007-04-29", 5) < RIGHT("1979-05-20", 5)) AS age;`
Here's an explanation.
• Apr 30, 2007, 03:31
zeeshanhashmi
great !!

Ok what if i use this :

\$date1 = "12/22/1897";
\$date2 = "01/08/1999";

if (\$date1 > \$date2)
{ echo "Date 2 is ELDER" ;}

if (\$date1 < \$date2)
{ echo "Date 1 is ELDER" ;}

I checked this its working. The only thing is that here we can set monthe like 13 and days like 32, for that i think we can have some check. Is there any other problem with this idea ? what u ppl think about it ?
• Apr 30, 2007, 03:37
kyberfabrikken
Quote:

Originally Posted by zeeshanhashmi
I checked this its working.

No, it's not. It will work, if you write the date in ISO-format though.
• Apr 30, 2007, 11:00
zeeshanhashmi
would u please enlighten the ISO Format. U must be thinking that i m asking FOOLISH questions, but actualy i am quite new to the programming.

Thansk & Regsrds
• Apr 30, 2007, 11:06
php_daemon
• Apr 30, 2007, 17:29
cranial-bore