PHP Age calculator

Age Calculator Using PHP function

Hello All, It is very exciting that here I am going to share with you a very good post threw which you can calculate your age by just providing your date of birth. It is a PHP age calculator which you can integrate with you PHP Project to use as an Age calculator.

Here I am using Three PHP functions to make this Module to calculate Age as given below:

1: date();

2: date_diff();

3: format();

Describing each function please check here:

Date() function : The date/time functions allow you to get the date and time from the server where your PHP script runs. You can then use the date/time functions to format the date and time in several ways.

Definition and Usage

The date() function formats a local date and time, and returns the formatted date string.

Syntax

date(format,timestamp);
date_diff() : by using this function you can find out difference between in two date time zone as I am using to differeciate date of birth and current date.
Definition and Usage

The date_diff() function returns the difference between two DateTime objects.

Syntax

date_diff(datetime1,datetime2,absolute);

Format() : The format of the outputted date string. See the formatting options below. There are also several predefined date constants that may be used instead, so for example DATE_RSS contains the format string‘D, d M Y H:i:s’.

The following characters are recognized in the format parameter string

Definition and Usage

The date_format() function returns a date formatted according to the specified format.

Syntax

date_format(object,format);

Please check it out with codes :

Html:

PHP:

JavaScript:

2 thoughts on “Age Calculator Using PHP function

  1. Hi there! I simply would like to give a huge thumbs up for the great data you have got here on this post. I will be coming back to your weblog for extra soon.

  2. Pingback: Maria Smith

Leave a Reply

Your email address will not be published. Required fields are marked *