This is a modified assignment from George Mason University for an intro to PHP and MySQL course. It does the following:
I used the built-in date diff method to calculate the age, and provide a breakdown of the age in years, months, and days. As well as calculate how many leap years occurred between the two dates.
For the class assignment, we had to create two histogram charts which displayed the age horizontally (with heading at the left) and vertically (with heading at the bottom). We had to split the age into individual numbers. Each number would have it’s own row or column depending on the projection. These charts are dynamic and the total amount of rows and columns change based on the data. Creating the vertical histogram chart was a bit tricky, but all I had to do was find out which was the largest number and use that for the max (plus one for the frequency heading) number of rows.
We also had to create a calendar which the end user could use to change the second date. I used the GET method to pass the date along. We needed to display options for the previous year, following year, months, and days within the chosen month. The calendar is dynamic and changes based on the chosen month which include: (1) Total amount of days in the chosen month and (2) trailing days in the first week which are not part of the chosen month
The months and days of the week on the calendar are not hardcoded. I used for loops to write them to the page. I also added conditional styling to highlight the chosen day on the calendar–this makes it easier to tell what day you chose.
The end-user is able to change the date of birth by using a form. This form uses the POST method to pass the data entered. I store this data in a cookie which expires when the browser is closed.
Just to make it clear, the design choice to vary how the end user chooses a Date of Birth and Age at Date was to display my abilities–I would not keep it this way in a real-life product because it can confuse and frustrate the end user.