The Time () and Date () Functions: The
time () and date () functions are the two most basic functions we use when working with dates in PHP. The time () function assigns each date and time a number string based in seconds. The date () function then
formats it to be human friendly.
The Mktime () Function: The
mktime () function is used to artificially generate the timestamp for an inputed date and time. This works the same as the time () function, except it is for a specified date, and not necessarily today's date.
The Cal_days_in_month () Function: The
cal_days_in_month () function tells you how many days are in a given month of a given year, for a specified calendar. This will come in handy in Februarys if you're not sure if it's leap year!
The Easter_date () Function: Easter changes date every year, but
this function helps determine when it is. This is helpful if you are dynamically adding holidays to your PHP calendar.
Counting Down: One simple script that deals with time is a
countdown script. This script counts the days, minutes, or even seconds until and event occurs. It is a great way lead up to a special event.
Adding Time: Another thing we can do is add time. A good example of this is our
pregnancy due date calculator where we add the baby's estimated gestation onto the last menstrual date to produce an estimated due date.
A simple calendar: Using many of the skills mentioned on this page we are able to create a
simple calendar in PHP. The calendar determines the number of days in the month, and the correct day of the week each falls on, to create a traditionally formatted calendar.