Home/Guides/PHP Date Format Examples

PHP Date Guides

PHP Date Format Examples

Common PHP date format tokens with examples for dates, times, and timestamps.

PHP date() formats a timestamp using a token string. Each character has meaning, so small mistakes can change the output.

Common tokens

Code examples

echo date('Y-m-d');
echo date('Y-m-d H:i:s');
echo date(DATE_ATOM);

Common errors

Use i for minutes. m is month. Set date_default_timezone_set() or configure date.timezone so output is predictable.

Try the PHP Date Format Tester.

FAQ

What is the most common PHP date format?

Y-m-d H:i:s is commonly used for readable database-style output.

What is the difference between m and i?

m is month. i is minutes.

Related tools

Related guides