PHP Most used Date format Example

Some of the important PHP date formats are given below with examples,

1. Printing time and day [12 hour format]:

<?php echo date('g:i, jS F'); ?>


3:51, 17th March

2. Printing time and day [24 hour format]:

<?php echo date('H:i, jS F'); ?>


15:52, 17th March

3. Printing month:date:year

<?php echo date('m.d.y'); ?>



4. Printing time with am/pm

<?php echo date('g:i a'); ?>


3:55 pm

5. Printing time(am/pm) with month, date and year

<?php echo date('g:i a, m:d:Y'); ?>


4:05 pm, 03:17:2014

1. y prints year in 2 digit format (eg: 2014 will be printed as 14 only).
2. Y prints year in 4 digit format (eg: 2014).

If you want to print in any other format, let us know in the comment area.

PHP Recommended Books:

377 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *