aMOEBa Posted July 20, 2010 Report Share Posted July 20, 2010 Hey guys I am trying to write this application to display members who are celebrating the birthday in a particular week, month. I want the app also to be able to display those who will be celebrating their birthdays in abt 2months. I want to do something like how Facebooks birthday alert is. Any idea is welcomed. Thanx. Quote Link to comment Share on other sites More sharing options...
LSW Posted July 20, 2010 Report Share Posted July 20, 2010 I would suggest you create a Adobe Flex application. There is a free SDK for that at Adobe and it will create a web app or if you choose AIR, it will be a desktop app. Basically it uses it is all built with Action Script and Flash (But not the Flash application, just the format.) Quote Link to comment Share on other sites More sharing options...
administrator Posted July 20, 2010 Report Share Posted July 20, 2010 Hi, If you are building this for a website, then you will need a database and say something like PHP. I would need more details to give you more details. Stefan Quote Link to comment Share on other sites More sharing options...
aMOEBa Posted July 29, 2010 Author Report Share Posted July 29, 2010 Hi, If you are building this for a website, then you will need a database and say something like PHP. I would need more details to give you more details. Stefan Hey Stefan, thanks for replying. I just want something similar to that of facebook. How facebook's birthday alert app works. I have db with members and their dates of birth. I want a message to appear on my homepage and other pages telling users who are celebrating their birthdays in a particular day, in the course of the week and also in the course of the month. Any idea will be much appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
CMR Posted July 29, 2010 Report Share Posted July 29, 2010 What you could do is something along the lines of this: Table Structure: userid - int (10) auto_increment primary key, username - varchar (50), userdob - varchar (25), // Any Other Fields... Store the userbirthday in this format: dd month YYYY (Eg: 10 April 1970, 03 December 1986, etc...) Now, using php you could take that string and turn it into timestamp using strtotime(), eg: //.... $userBirthday = "29 December 1987"; // Eg: This variable may equal 10 April 1970, You WOuld get it from the DB, eg: $user['userdob'] $explode = explode(" ", $userBirthday); // Break it down into the day, month and year $birthDay = $explode[0]; $birthMonth = $explode[1]; $birthYear = $explode[2]; //Now we can add the birthDay, birthMonth and this year (eg: 29 December 2010) to make a timestamp and find out exactly when their birthday is this year $birthString = "".$birthDay." ".$birthMonth." ".date('Y'); $birthTimestamp = strtotime($birthString); // Next we can compare it to the current timestamp to see if they have already had their birthday this year, because if they have then there's no point continuing, they will just have to wait until next year $now = time(); // Current Timestamp if($birthTimestamp > $now) { // Okay Let's Continue // It's worth noting that this is a very basic example, so in reality you would want to actually check more throughly, eg: Okay their birthday may not be in the future, but what if it only happened a few hours ago? So what if it is their birthday today? This example would ignore that and only continue if their birthday is still yet to happen // Okay so we know their birthday hasn't happened yet, so can we find out when it is? $difference = $birthTimestamp - $now; // The time left between now and their birthday - In Seconds // You could then break this $difference down into minutes, hours, days, weeks, months etc.. eg: $type = 'Seconds'; $difference = $difference / 60; // This is now the time in minutes until their birthday $type = 'Minutes'; $difference = $difference / 60; // Hours $type = 'Hours'; $difference = $difference / 24; // Days $type = 'Days'; $difference = $difference * 0.14285; // Weeks $type = 'Weeks'; $difference = $difference * 0.22998; // Months $type = 'Months'; $difference = round($difference, 2); /****************************************************************************************************** * You will notice that the maths above is pretty crap, you may want to do it...well...unlike me... ******************************************************************************************************/ // Etc... // Again you'll want to do it more thoroughly though, eg: Checking if there is at least 1 hours left before converting to hours, otherwise you'll end up with it being "0" or "0.n" if you round() it // SO you could then simply display that if you wanted to, something like $newAge = date('Y') - $birthYear; echo "There is " . $difference . " " . $type . " left until your birthday. You will be ".$newAge." years old!<br>"; // Or you could do more checks, eg: you could display it only on round occasions, eg: 2 Months, 1 Month, 3 Weeks, 2 Weeks, 1 Week, etc... whatever you want really } //.... Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.