Date and Time

Date and Time are pretty much important features required for any real world website. For example you want to store the date of registration of the user or the user buys a certain product on a particular date and time and then it needs to be delivered to him within some time period, all these things account for the presence of date and time features.

PHP provides various date and time functions, through which we can validate a date whether it is correct or not or we can create a corresponding date, if we know the time stamp.

In this lesson we will take an example of a User Signing up with a field of Date-Of-Birth. Thus we will use PHP Date and Time functions to validate the entered Date.  In this way will be able to see the Date and Time Functions of PHP.

First we will make the default time-zone of our Apache Server to America/New-York, and see that you get the present date output correct, when you run the below snippet of code provided. You can find your time zone definition format on the link below 

http://php.net/manual/en/timezones.php

Get hands-on with 1200+ tech skills courses.