PHP Date() Function
August 26, 2010 # 4:55 PM # Code, PHP Functions # No CommentThe date() function converts a given timestamp into a readable date format.
Here is the syntax for this function:
Syntax
date(format,timestamp);
Parameters:
format
This parameter determines the format and how the date will read.
For example: “Saturday, Nov. 16th 2009” would be the following code:
$timestamp = time();
date("l, M. jS Y",$timestamp);
timestamp
This parameter is the timestamp you want to use to format a date from. This timestamp is a number of seconds since a certain date, since we used the current timestamp of time() we are making the date for the current time.
We’ll break down our example to see what each set of letters represents as part of the date’s format.
- l – day of the week, textual, long; i.e. ‘Friday’
- M – month, textual, 3 letters; i.e. ‘Jan’
- j – day of the month without leading zeros; i.e. ’1′ to ’31′
- S – English ordinal suffix, textual, 2 characters; i.e. ‘th’,‘nd’
- Y – year, 4 digits; i.e. ’1999′
View the complete date format reference here.
Popularity: 1% [?]

Subscribe RSS
Comment RSS






