PHP Script – Formatting Date And Time

Formatting a date time in PHP is pretty easy. you just need to use date function (Format: string date(string $format[,int $timestamp])).

Here are available date and time variables:


d – day of the month 2 digits (01-31)
j – day of the month (1-31)
D – 3 letter day (Mon – Sun)
l – full name of day (Monday – Sunday)
N – 1=Monday, 2=Tuesday, etc (1-7)
S – suffix for date (st, nd, rd)
w – 0=Sunday, 1=Monday (0-6)
z – day of the year (1=365)


W – week of the year (1-52)


F – Full name of month (January – December)
m – 2 digit month number (01-12)
n – month number (1-12)
M – 3 letter month (Jan – Dec)
t – Days in the month (28-31)


L – leap year (0 no, 1 yes)
o – ISO-8601 year number (Ex. 1979, 2006)
Y – four digit year (Ex. 1979, 2006)
y – two digit year (Ex. 79, 06)


a – am or pm
A – AM or PM
B – Swatch Internet time (000 – 999)
g – 12 hour (1-12)
G – 24 hour c (0-23)
h – 2 digit 12 hour (01-12)
H – 2 digit 24 hour (00-23)
i – 2 digit minutes (00-59)
s 0 2 digit seconds (00-59)


e – timezone (Ex: GMT, CST)
I – daylight savings (1=yes, 0=no)
O – offset GMT (Ex: 0200)
Z – offset in seconds (-43200 – 43200)
r – full RFC 2822 formatted date


    //By    : Xhanch Studio
    //URL   :
    //Prints something like: Monday
    echo date("l");

    //Prints something like: Monday 8th of August 2005 03:12:46 PM
    echo date('l jS \of F Y h:i:s A');

    //Prints: July 1, 2000 is on a Saturday
    echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));

    //prints something like: Mon, 15 Aug 2005 15:12:46 UTC
    echo date(DATE_RFC822);

    //prints something like: 2000-07-01T00:00:00+00:00
    echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));

Incoming Search Terms

prayer time php script, php internet time, script swatch internet time, php date formatting script, PHP Date and Time Script, time php script, php script date format, php script time format, script number format php, script for php like facebook date and time, php date format script, php swatch internet time, php tutorial, php script to format date, php script menampilkan time ago mktime ago, Php script membuat mktime ago, php script intenet time, php script formater, PHP script format, php program prayertime, php prayer time tutorial, php swatch internet time script, php time formatter script, php time script with format, php format time, pretty date php script like twitter, program terbilang 2 digit, Script ( Date/Time - DATE(2000 1 7) 7), script php cu formatare date, script php number format, swatch internet time, swatch internet time php, swatch internet time script, time and date format in php script, tutorial membuat prayer times di php, xhanch prayer 12 hour format, xhanch wordpress seconds ago, manga php script 2011, convert time format Delete 7/14/2011 4:17:48 PM php, date and time scripts for websites, date format in php script, date format in script in php, date formats script php, date formatting php script, date php script, date(date_atom mktime, date(DATE_ATOM), Facebook mktime ago, facebook php time format script, format time php script, free php script time(); ago, in php convert date format to internet time, l js \of f y h:i:s a conversion to other format php, php internet time script, membuat php script time hour minute seconds ago, membuat time ago php, Membuat-script-datetime-ago, O - offset GMT (Ex: 0200), php code for date form, php code to format date, php code to get the two digit year, php date 3 letter day, php date 3 letter day script, php date format scripts, php date(DATE_ATOM mktime()), php format date time, php format date time script, php format internet time, code fungsi terbilang as3, Xhanch, Xhanch Studio

Posted on 2010-10-22 by Susanto BSc in Free Script, PHP Script
Date Time, Date, Php Manual, Date Time Formatting, Free, Time, Php, Php Tutorial, Script, Date Formatting, Time Formatting, Format, Code, Tutorial, Xhanch, Xhanch Studio

Tagged as: , , , , , , , , , , , , ,

Leave a Reply

You must be logged in to post a comment.