CancelImage Upload

PHP Date and Time Format Reference Guide

Using the PHP function date() the current date and time can displayed numerous ways. Here then is a reference guide to help demonstrate these numerous formats and their respective codes.

24 Hour time format: 16:06

echo date("H:i");

24 Hour time format without leading 0: 9:02

echo date("G:i");

12 Hour time format with AM and PM: 04:08:03 pm / 09:12:38 am

echo date("H:i:s a");

12 Hour time format without a leading 0 plus AM and PM: 4:08 pm / 9:12 am

echo date("g:i a");

Day of the week: Tuesday

echo date("l");

Returns one if we are in a leap year, zero if not:

echo date("L");

Date with leading zeroes: 01/07/2009

echo date("d/m/Y");

Date without leading zeroes before month and day: 1/7/2009

echo date("j/n/Y");

Date with written month: 30 July 2009

echo date("d F Y");

Current month in short form: Jan, Feb, etc

echo date("M");

Number of days this month

echo date("t");

Seconds since unix time started (1.1.1970)

echo date("U");

Numeric values of the day of the week

echo date("w");

Short form of year: 00

echo date("y");

Numeric Day of the Year

echo date("z");

Difference to time zone in seconds

echo date("Z");


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com