Sorry guys, but this is now very urgent! This could be the last issue.

Ok, so the real problem is now that the code for the age stamp... FINALLY WORKS!! But there is still one problem: the age comes in user's profile as the current year, like in every user's age field it says "2011", and I want to be shown as an person's age, not a year.

 

Here is the code:

 

    $year_diff = date("Y") - ($user->profile_dob{year});
    $month_diff = date("m") - ($user->profile_dob{month});
    $day_diff = date("d") - ($user->profile_dob{day});
    if ($month_diff < 0)
      $year_diff--;
    elseif ($month_diff == 0 && $day_diff < 0)
      $year_diff--;
print $year_diff;

 

I found this on google, but can you tell me what is wrong with that code?

  • TSFI

    oh c'mon, why won't anybody answer, I promise this will be the last very problematic error ever in my site. I just need to know what is the code to the age calculation which shows a different age in every user, like I don't want the current year or the same age shown in all user's profile..

    I'm getting reeeeeally tired with the php if you can't really help me..

    And I don't want codes with the "function utility()" neither codes with someone else's birthdate. -.-""

  • TSFI, we are getting tired of your unfriendly attitude towards the community-members who are in general helpful to each other. Please, don't give the excuse that you behave in such manner because you have some disease. In that case, you should come back when you think you are fit enough.

    No one can spoonfeed you always. But, if you are keen to get some hints to resolve your issues, you should first start appreciating what people are giving you. People here can take you to the water, cannot make you drink and there is no reason why they should,

    Your way of posts GENUINELY harm the healthy atmosphere here. If you want everything so QUICK, I would advise you either to learn Php well or hire a developer from the pro group.

    Or, if you're so tired, you could alway quit elgg, no one's gonna pull you back, dear. ;)

  • TSFI

    I know, but I was going to say nevermind, I'm going to learn php :D

     

    Sorry, I know I'm bit weird.

  • With only some fragments of code posted it's IMPOSSIBLE to tell you why it doesn't work.

    The code above seems alright. But if you get the same year for the age of every user instead of their age, this piece of code is surely not included correctly within the rest of your code. Are you sure that the variables have the correct values when this piece of code is executed? Maybe you could print out the intermediate results for testing.

    You get the same year and it happens to be the current year (2011)? So,  one possibility is that the age variable gets initialized somewhere with the current year. Then the calculation happens without writing the result to the age variable. So, this variable still has the init value, i.e. the current year.

    Or the DOB variable only contains ZERO entries (not initialized correctly?). Then the difference between the current date and the DOB would be ZERO ---> current year would be the "age".

  • Yes that calculation is correct, which means that $user->profile_dob{year} is not the correct method of obtaining the users date of birth.

  • Before $user->profile_dob{year} will contain the correct birthdate it surely needs to get initialized. Unfortunately, this part of the code is missing. It might only be missing in the code fraction posted above, but maybe it also misses in the complete code...

  • TSFI

    "TSFI, we are getting tired of your unfriendly attitude towards the community-members who are in general helpful to each other. Please, don't give the excuse that you behave in such manner because you have some disease. In that case, you should come back when you think you are fit enough."¨

    LOL! Wait a second! What the heck are you actually blaming me? I wasn't unfriendly, and if I were, could you show a post which I posted so it shows how I was unfriendly.

     

    Your message offended me sooo much. And btw, my Asperger thing is NOT an "excuse", it's the truth! And even if it's an excuse, I still can give that excuse. And btw, your opinion about my Asperger was disability-racist!

     

    I wanna say the meanest bad words and sentences ever, but I cannot say.

     

    And also, I think I was friendly to the people who helped me, I even said "Thank you so much! :)", but still, I sometimes could say "oh c'mon", "¤¤#¤&)", or whatever else, but you are directly blaming me because of that. YOU ARE SUCH A DISABILITY-RACIST!

  • TSFI

    @Shouvik: I'm also gonna report you because of your disability-racist manner. Don't understand what is disability-racist? It means a person who is racist to people with Asperger, Down Syndrome, Alzheimers or whatever but you are still that.

  • TSFI

    @Shouvik: Also, congrats, you are reported now :)

    And you or any other person have/has NO RIGHTS to report me because I haven't done nothing, only you have done.

  • TSFI

    And I'm not being a bully bitch, I'm being angry because of reason. And I'm sad also.