PHP Date Formats Cheat Sheet
Shawn Mosher on November 11, 2010 in PHP | 3 Comments
11-15-2010
If you want the date to be in all numbers well use m for the month, d for the day and Y for the year. If you only want to display the last two digits of the year use y. Using y would output 11-15-10.
1 | <?php echo date("m-d-Y"); ?> |
Keep in mind that using d will output the day leading with 0 if the day is before 10. Example: 01, 02, 03, 04, 05, 06, 07, 08, 09. If you dont want the leading 0 to display, use j instead.
Jan 6, 2010
For the first three letters of the month to be display like Dec use M.
1 | <?php echo date("M j, Y"); ?> |
December 6, 2010
For the full months name to be displayed like December 3, 2010 we’ll use F.
1 | <?php echo date("F j, Y"); ?> |
Thu, November 7th, 2010
For the days name (Fri, Sat, Sun, Mon, etc.) we’ll use D. Also if we place S behind the date it will show th, sn, rd or nd.
1 | <?php echo date("D, M jS, Y"); ?> |
Remeber that these values can be used in any order that you would like. For more options, be sure to check out this helpful reference.


Hi,
thanks for the tipps, but i think you got a mistake in the last line:
This is what i get when i write:
—> Sun, Dec 1217, 10
Or am i missing sthg?
greets
Hi Christoph,
I think you might have a lower case “S”. Try a lower case “j” and upper case “S”. So it should be “jS”. upper case and lower case letters will effect the output so make sure it’s exactly as you see it.
Great job! Thanks for sharing your concept. I think personally everybody should read the post.
web design in Pakistan