|Lessons||PHP Date and Time Functions|
The date() function returns the current server timestamp. It is formatted according to a set of parameters. The syntax of data() is as under:
If the timestamp parameter is not provided, the current timestamp is assumed. Following table shows the available formats.
date() Function Formats
The checkdate() function is used to validates a given date. Successful validation means that the year is between 0 and 32767, the month is between 1 and 12, and the proper number of days is in each month (leap years are accounted for, as well).
The syntax of checkdate() follows:
checkdate(month, day, year);
The mktime() function returns the UNIX timestamp as a long integer (in the format of seconds since the Epoch, or January 1, 1970) for a given date. The primary use of mktime() is to format dates in preparation for mathematical functions and date validation.
The syntax of mktime() follows:
mktime(hour, minute, second, month, day, year);
time() and microtime()
The time() function returns the current system time, measured in seconds since the Epoch.
The syntax of time() function follows:
The result of the above could be such as 958954466.
Calling microtime() function adds a count of microseconds, so instead of just receiving a result like above, we could get a result like 0.93121634 958954466, at the exact moment we asked for the time since the Epoch (includes both seconds and microseconds).