PHP Date format

For create date at PHP we use The PHP Date() Function

The PHP date() function formats a timestamp to a more readable date and time

date(“format”)

Format Parameter :

Parameter Description
a for “am” or “pm”
A “AM” or “PM”
d The day of the month (01-31)
D Name of day, start from Sunday, just 3 char, ex : “Fri”
m The current month, as a number (01-12)
F Name of month, full word, like “January”
M name of month, just 3 char, like “Feb”
n The current month, as a number, without “0″( 1-12 )
Y The current year in four digits, like : 2008
y The current year in two digits, like : 08

Using at PHP Code :

<html>
<body>
<?php
echo date(“Y/m/d”);
echo “<br />”;
echo date(“Y.m.d”);
echo “<br />”;
echo date(“y-m-d”);
echo “<br />”;
echo “today is “. date(“F d, Y”);
?>
</body>
</html>

And output will shown like this ( If today is 2008/05/03)

2008/05/03
2008.05.03
08-05-03
today is May 03, 2008

Leave a comment

4 Comments.

  1. You know this is a very good post i hadent thought about this for quite a while and you have like sparked me to look into it further and re educate my self in the subject….thanks,hope to see more of your posts soon

  2. What I wouldnt give to have a debate with you about this. You just say so many things that come from out of nowhere that Im fairly sure I would have a decent shot. Your site is great to look at, I mean people wont be bored to tears. But others who can see past the videos and the layout won’t be so impressed with your generic knowledge of this topic.

Leave a Reply


[ Ctrl + Enter ]

Trackbacks and Pingbacks:

  • Forcescript.com – PHP Include File - Pingback on 2008/05/03/ 13:48