PHP » Miscellaneous » date()

Syntax:
string date(string format [, int time])
format
How to format the date.
time
Time (seconds since January 1, 1970) that should be formatted.

Returns a formatted date string.

The date() function returns a string with the current date and/or time, formatted as specified in the format parameter. If the optional time paramater is not specified, the current time is used. A list of the formatting codes available follows.

CodesFormat
a am/pm
A AM/PM (capital letters)
B Swatch Internet time
d Day of the month (two digits)
D Day of the week (three letters)
F Month name
g Hours (between 1 and 12)
G Hours (between 0 and 23)
h Hours (between 01 and 12, two digits)
H Hours (between 00 and 23, two digits)
i Minutes
I 1 or 0, depending on daylight savings time
j Day of the month (no leading zeros)
l Day of the week
L 1 or 0, depending on leap year or not
m Month number (two digits)
M Month name (three letters)
n Month number (no leading zeros)
O Offset to Greenwhich Mean Time (number of hours)
r RFC822 formatting
s Seconds (two digits)
S Ordinal suffix for day number (st, nd, rd, th)
t Number of days in the month
T Time zone
U Seconds since January 1, 1970
w Day of the week as a number
W Week number (ISO-8601)
y Year (two digits)
Y Year (four digits)
z Day of the year
Z Offset to UTC as a number of seconds

Examples

Code:
<?php

print date("g:iA F jS, Y", 1200000000);

?>
Output:
10:20PM January 10th, 2008
Explanation:

A date 1,200,000,000 seconds from January 1, 1970 is formatted using the date() function.

See Also: