MyBB Community Forums

Full Version: PHP Day of birth
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my quest to learn PHP I made a little script that tells you what day you where born on, using an algorithm I was taught at college. I wrote it all myself, no copying and pasting anything, just had to look on a PHP site or two to see how to set something out.
[attachment=12501]

I'd say it's about 99% accurate. Most of the dates I've tried work; very few are wrong, and some show the error I put in if it can't work out the day (not too sure why it happens though) and I've also disallowed years that are 2000 and after, as the equation doesn't like the 0s. I've added something to show a message if you enter a date that doesn't exist (30/31 Feb, 31 Apr/Jun/Sep/Nov), put in something if you select 29th Feb in a non-leap year, and if you try to put 29th Feb in certain century years that aren't leap years (a century is only a leap year if divisible by 400, i.e. 1200 and 1600).

There's probably a lot wrong with it and many was to make things better but I'm still learning Angel

Comments?? Smile
What do you know. I was born on a Friday.

http://dloos.homelinux.com/~ryan/birthday.php
You got it correct. I was born on Friday!
Born on Saturday. Smile
Sunday.
I've added in something now to check leap years and disallow it if you try to select 29th Feb in a non-leap year.

Yay Big Grin
Thursday. woo! Good job, MattSmile
Sunday. Smile
Friday.. Smile
I was also born on friday.
08/11/89.