Date/Time Functions Demo

Functions demonstrated
<?date($format,$time)?>
<?gmdate($format,$time)?>
<?time()?>

The date() function is used to display times and dates in various ways. The function takes a format string and a time as arguments. If the time argument is left off, the current time and date will be used. The time argument is specified as an integer in number of seconds since the Unix Epoch on January 1, 1970. The format string is used to indicate which date/time components should be displayed and how they should be formatted.

For example, if we wanted to print the current date and time, we might use a tag like: <?echo date("D M d, Y H:i:s")?>. This looks like:

In the above you will find that the various characters in the formatting string were replaced with a date/time component. Any characters not replaced with anything were displayed verbosely. The valid formatting characters are:

The gmdate() function is identical to the date() function except that it uses Greenwich Mean Time instead of the current local time.

The time() function simply returns the current local time in seconds since Unix epoch. It is equivalent to calling date("U").