Date and time Class , objects and function in PHPThe object oriented features are added from PHP 5 onwards. So several date functions can be used but many such objects were supported from PHP5.3 onwards so check your server PHP version to know before using all these features.
How to know PHP version installed in your server ?
Date & time functions are hereDisplaying date and time
How to display current time stamp value in a page? By using time stamp we can display the date and time by formatting the time stamp output. Learn how to set the time zone of the server or at the page level.
Validating date and finding date parts from a date string
We need to check the user entered date value in any web page before using in our script. For this php built in date function checkdate can be used. This function returns true if the date is a valid date. This function also takes care of leap years and other date restrictions.
Today's date & time
We can display today's date & time in any format we want by using date function in PHP. This function takes the current time stamp ( or any time stamp value ) as input and returns the date & time value.
Previous dates or advance dates from today
How to get date parts to display previous or advance dates by calculating from the present date.
Table of characters used in formatting date outputs used in different date & time functions.
Here is a script to generate timestamp based on the selection of date, month, year, hour , minute and seconds.
Drop down list box for date month selection
It is easy for a user to select month, date etc from a drop down list box than entering them in a text box. Here the data entered by the user will be under control as from a given options the user has to select one.
This function mktime is used to generate timestamp from a given value of date and time
By using mktime function we can get the difference in day or month or year between two dates.
Date parts of a day
By using timestamp and gatedate function we can get the date parts like month, year, date , day of the week etc of any given day.
Date value from string variable
From a string variable consist of months or days we can use array split command to get the date parts.
More On Date Object
PHP Date & Time class creating and examples of uses
Creating a date interval object and using with php date object
Adding date interval to date object to create new dates
Difference in date by using diff function and using date object
Add or subtract from date object using modify function
Changing parameters of the date object by using setdate function
updating time for a date object to a new value
Gettign the time zone setting of the server
Setting the default time zone of server
Array of time zones available for setting ( total list )
Getting time in seconds elapsed from Epoch time
Local time of the server or different time zones by using localtime() function