Home » Code, PHP Functions

PHP Date() Function

The 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.

0

Popularity: 1% [?]

Share/Bookmark this!

Leave a reply

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally recognized avatar, please register at Gravatar.

Side Notes

This entry was posted by on August 26, 2010 at 4:55 PM and filed under Code, PHP Functions category.

You can add your comments or trackback from your own site. To keep you updated to the latest discussion, you can subscribe to these comments via RSS.

Recent Entries

Pages

Recent Comments

Resources

Questions & Answers

Just started! Have not answered any questions.

Tag Cloud

background body CSS database date dropdown email error_reporting favicon file filesize form format function global hosting HTML image Javascript limit link linkbar mysql numbers online option ordinalize pagination pattern photoshop PHP resize rows script search snowing stylesheet switch table thumbnail time timestamp upload validate variables

Sponsors