php date time format

Php date() function returns date format by using timestamp.
date(format,timestamp);
The timestamp argument is optional. If it is not given by default the value of time() is used.
Now see the example of date function for getting mysql date format.
<?php
echo date("Y-m-d H:i:s"); 
//Result is
2012-10-01 15:12:20
?>


See comman characters which are used for making different date formats. tr>
CharacterDescription
Day related Characters
d Day of the month with leading zeroes like 01,02 etc.
DShort name of the day Like Mon, Tue...Sat and Sun etc.
lFull name of the week day like Monday, Tuesday
wNumeric value of the week day like 0 for sunday, 1 for Monday, 2 Tuesday
dSFor 2nd,10th date etc.
Month related Characters
FFull name of the month Like January, Feburary etc.
m Numeric value of the month 01 for January, 02 for Feburary ... and 12 for December.
nNumeric value of the month without leading zero 1 for January, 2 Feburary ... and 12 for December.
MShort name of the month like Jan, Feb, Mar... and Dec.
Year related Characters
LReturns 1 if leap year otherwise 0
Y4 digits numeric value of the year Like 2010
y2 digits numeric value of the year Like 10 and 11 etc.
Time related Characters
a am or pm ( lowercase )
A AM or PM ( Uppercase)
g12-hour format without leading zeroes. From 1 to 12
G24-hour format without leading zeroes. From 1 to 23
h12-hour format with leading zeroes. From 01 to 12
H24-hour format with leading zeroes. From 01 to 23
iMinutes with leading zeroes. From 00-59
s24-hour format with leading zeroes. From 00-59
Zone related Characters
eReturn timezone identifier
O Difference from Greenwich time (GMT) in hours without colons +530
P Difference from Greenwich time (GMT) in hours and with colons +5:30
See some more examples of date format
<?php
echo date("d,F Y H:i:s")."<br/>"; 
//Result is   01,October 2012 12:48:53  
echo date("d.m.y H:i:s")."<br/>"; 
//Result is   01.10.12 12:48:53  
echo date("d-m-Y H:i:s")."<br/>"; 
//Result is   01-10-2012 12:48:53  
echo date("d/m/Y")."<br/>"; 
//Result is   01/10/2012    
echo date("H:i:s")."<br/>"; 
//Result is   12:48:53  
echo date("h:i:s A")."<br/>"; 
//Result is   12:48:53 PM
?>