SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: Problem with Year < 1900
-
Apr 29, 2007, 09:36 #1
- Join Date
- Nov 2005
- Location
- Karachi - Pakistan
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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, 09:52 #2
- Join Date
- Jan 2006
- Location
- Manchester, UK
- Posts
- 627
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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, 09:53 #3
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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, 10:48 #4
- Join Date
- Nov 2005
- Location
- Karachi - Pakistan
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
Please guide.
-
Apr 29, 2007, 10:51 #5
- Join Date
- Jan 2006
- Location
- Manchester, UK
- Posts
- 627
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK, I get ya ... I suppose I would go with kyberfabrikken's advice
-
Apr 29, 2007, 10:55 #6
- Join Date
- Nov 2005
- Location
- Karachi - Pakistan
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
can u people gudie me how to do my tasks through that u 've suggested ?
-
Apr 29, 2007, 11:54 #7
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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;
-
Apr 30, 2007, 04:31 #8
- Join Date
- Nov 2005
- Location
- Karachi - Pakistan
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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, 04:37 #9
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 30, 2007, 12:00 #10
- Join Date
- Nov 2005
- Location
- Karachi - Pakistan
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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, 12:06 #11
-
Apr 30, 2007, 18:29 #12
- Join Date
- Jan 2002
- Location
- Australia
- Posts
- 2,634
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Adodb_date may be helpful for you.
It massively extends the date range workable by PHP
http://phplens.com/phpeverywhere/adodb_date_library
Bookmarks