How to convert a timestamp into a readable date in PHP

A UNIX timestamp is something like a 10 digit (or less) integer number which represents the elapsed seconds since the 1st of January 1970 (also known as the Unix Epoch). It’s a very accurate representation of time, but not necessarily something us humans easily understand.

A Unix Timestamp looks something like 1367805780.

We can use PHP’s date() function to turn it into something more readable, such as 05/05/2013, or 5th of May, 2013 at 10:03pm. Here’s how:

	$theTimestamp = 1367805780;
	echo date('m/d/Y', $theTimestamp);

	// result: 05/05/2013

The first parameter tells date() how to format its output – and you can get extremely creative with it:

	$theTimestamp = 1367805780;
	echo date('l jS \of F Y h:i:sa', $theTimestamp);

	// result: Sunday 5th of May 2013 10:03:00pm

The slightly eerie looking combination of letters and numbers is made up of “real” printable characters (such as the “of” in “5th of May”) and special switches that represent each date component.

For a full reference and plenty of examples have a look at the PHP Manual:

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at and