Archive

Posts Tagged ‘php date format’

Human Readable Date Format List for PHP date Function

July 28th, 2008 No comments

PHP offers a large variety of arguments that can be passed to the date() function. You are able to almost everything you want having just the current time stamp. I’ve selected the most useful readable formats – I think you might need it for any purpose. I used it to randomize a site’s content to vary posting dates. So, here is the list:

F j, Y
F j, y
F d, Y
F d, y
d-M-Y
d-M-y
j-M-y
j-M-Y
d/n/y
d/m/y
d/n/Y
d/m/Y
j/m/y
j/m/Y
j/n/y
j/n/Y
Y-m-j
Y-n-j
Y-m-d
Y-n-d
n/d/y
m/d/y
n/d/Y
m/d/Y
m/j/y
n/j/y
m/j/Y
n/j/Y
d.m.Y
d.m.y
d.n.Y
d.n.y
j.m.Y
j.n.Y
j.m.y
j.m.y
m-j-Y
n-j-Y
m-d-Y
n-d-Y

Most of these date formats look well and I hope you find it useful

Useful Date Formats in PHP

May 3rd, 2008 No comments

Often you need to generate a timestamp with PHP. It should represent the current date or the date in the future. It should show the date, month and year in all possible readable formats. I’ve created a list that has most often used date formats. Here it is:

F j, Y
F j, y
F d, Y
F d, y
d-M-Y
d-M-y
j-M-y
j-M-Y
d/n/y
d/m/y
d/n/Y
d/m/Y
j/m/y
j/m/Y
j/n/y
j/n/Y
Y-m-j
Y-n-j
Y-m-d
Y-n-d
n/d/y
m/d/y
n/d/Y
m/d/Y
m/j/y
n/j/y
m/j/Y
n/j/Y
d.m.Y
d.m.y
d.n.Y
d.n.y
j.m.Y
j.n.Y
j.m.y
j.m.y
m-j-Y
n-j-Y
m-d-Y
n-d-Y

Usage is quite simple.

<?
$guess=mktime (0,0,0,date(“m”),date(“d”),date(“Y”));
$data=date($dateformat, $guess);
?>

Just use the date format you like and set the date for formatting (it is set to today by default) and insert this code anywhere you need to have the date displayed in the appropriate format.