matfish Posted June 27, 2007 Share Posted June 27, 2007 Hi, Iv got a popup calendar which your able to select a date in the format of dd-mm-yyyy, I then want to display that persons age after selecting the date. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/57453-age-calculation/ Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 The thought that a lot of people have all ready created a function to do just that came to my mind and yup that function can be found with google. http://www.javascriptkit.com/script/script2/calculateage.shtml just a matter of linking the functions togehter and your done Quote Link to comment https://forums.phpfreaks.com/topic/57453-age-calculation/#findComment-284353 Share on other sites More sharing options...
matfish Posted June 28, 2007 Author Share Posted June 28, 2007 Hi, Thanks for the link. If I was confident enough with javascript I would have figured it out by now. Its not exactly overcoming the problem that when Iv selected the date, I need to calculate the age from a dd-mm-yyyy format (if I could explosed the date like I would in php I wouldnt have an issue). Any ideas? Take a date from dd-mm-yyyy in an input box and explode it to format: displayage(yyyy, mm dd, "years", 0, "rounddown") ? Quote Link to comment https://forums.phpfreaks.com/topic/57453-age-calculation/#findComment-284879 Share on other sites More sharing options...
RichardRotterdam Posted June 28, 2007 Share Posted June 28, 2007 Javascript split maybe if the input value is a string that is function divide_string() { var dateInString="12-01-2001"; var date_array=dateInString.split("-"); alert("day="+date_array[0]+" month="+date_array[1]+" year="+date_array[2]); } Quote Link to comment https://forums.phpfreaks.com/topic/57453-age-calculation/#findComment-285124 Share on other sites More sharing options...
matfish Posted July 3, 2007 Author Share Posted July 3, 2007 Hi, Many thanks! With the above, Im now able to pass the variables of dd-mm-yyyy through another script to calc the age. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/57453-age-calculation/#findComment-288624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.