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

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

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

Leave a Reply

You must be logged in to post a comment.