Date Function

Date FunctionThe date function turns the symbols displayed in the date format symbols table into the examples also shown in the table.

Date Format Symbols
Symbol Meaning Example
M Month in text, abbreviated Nov
F Month in text not abbreviated November
m Month in numbers with leading zeros 02, 12
n Month in numbers without leading zeros 1, 12
d Day of the month; two digits with leading zeros 01, 14
j Day of the month without leading zeros 3, 30
l Day of the week in text not abbreviation Friday
D Day of the week in text as an abbreviation Fri
w Day of the week in numbers From 0 (Sun) to 6 (Sat)
Y Year in four digits 2005
y Year in two digits 05
g Hour between 0 and 12 without leading zeros 2, 10
G Hour between 0 and 24 without leading zeros 2, 15
h Hour between 0 and 12 with leading zeros
01, 10
H Hour between 0 and 24 with leading zeros 00, 23
i Minutes 00, 59
s Seconds 00, 59
a am or pm in lowercase am, pm
A AM or PM in uppercase AM, PM

The parts of the date can be separated by hyphens (-), dots (.), forward slashes (/), or spaces.

Example:

<?php $today = date("l–j F Y"); echo "$today";?>

Preview:

Tuesday-28 November 2006


Related Articles

  • Count Down
    This will let you count the number of days remaining to reach a given event : for instance days left before we reach the year 2010
  • Last Modified and User's Screen Resolution Detection
    An easy and efficient way to write the date a file was last modified.
    We call the function filemtime() that returns an integer (the number of seconds elapsed from Jan 1st, 1970 00:00 GMT) Anyway, to make this integer viewable by human beings, we just format it using date() function.
  • Relative Dates
    In this tutorial I am going to teach you how to create your own relative date function.
  • Make a Calendar
    Using PHPs calendar functions, make a stylish dynamic calendar showing weekends, current month and more.
  • Last Modified, Loading Time, Preload your Images
    Last Modified, Preload your Images, Loading Time. In this tutorial you will find scripts for this topics.
  • Date of the Day in PHP
    This is a simple script but yet very useful, it consists on : catching the date, applying a given display style to it and finally showing it up. In this tutorial we are going to choose this display style: Day of the week - Month - Day of the Month - Year - : for instance today is Wednesday May 25 20...
  • Custom Greeting
    In the last tutorial we learned how to display the time using php. Now this is cool and all but lets get even cooler and learn how to put that time to work and display custom greeting depending on the time of day.
  • Javascripts For Your Website
    Here is a list of short but invaluable Java scripts you can insert into your own site code to implement a number of small but extremely useful features.
  • PHP Functions
    Go to the next level in PHP
  • Date and Time
    Display the current data and time using a very small and common code.

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.