, , , ,

Get Age from Date of Birth using PHP


 To get current year/s of age in PHP, You need to find the difference and subtract the date of birth input by the user to the current date.

Prepare your index.php. I am using bootstrap 4 framework and  fontawesome icons as a front-end for this project.

Declare your main page like this.

I declared the class of the <body> as bg-warning for background color purposes. But you can also manipulate using CSS and experiment as yourself.

Inside the <body>, Place a bootstrap card holding by a column and row which holds by a container.

We will need a form to hold the input of user's date of birth. Place this code at the top of the document to handle the submission of the form later and this is where the calculation happen.


After that you can now place this form into the card we created earlier.

Lastly create another card right after the first card we created to display the output age of the user with the use of PHP to verify the user's input.



The output of the project should be like this.

Before user input.


After the user input and submits the form.



You can download the full source code below.

SOURCE CODE
1. Download the source code & place it on your host.
4. Test it on your host.

DOWNLOAD IT HERE -> DOWNLOAD

Enjoy !
Please share this if you find it helpful. Thank you.
Share:

No comments:

Post a Comment