MySQL DATE_FORMAT() / PHP date() tool

 

Other Resources

Official documentation: Some other stuff I've created for MySQL+PHP programming:

With this tool, you can quickly determine the correct format specifiers to use when outputting date/time values using MySQLs DATE_FORMAT and/or PHPs date() functions.

Simply pick the data type (second, minute, day, year, ...), then say which format you want to use for that data type. As soon as you select or type something into the various lines, the result is checked against a live PHP and MySQL installation.*

I hope you will find it useful! If you have any questions or comments, please do not hesitate to contact me at carsten (at) bitbybit (dot) dk.

The chosen format is immediately checked against a MySQL and PHP server (due to web hosting limitations, the used versions of both programs may be quite dated.)

Note: Although presented side-by-side in this page, there is not a one-to-one relationship between PHP and MySQL date/time format specifiers. Not only are there options specific to one and not the other, there are subtle (and not so subtle) differences between the two. As an example, both formatters have a "day in year" specifier. For PHP, the range is 0..365; for MySQL, the range is 1..366.

1. Set data type and format.

Click to add more date/time fields.

Data Formatting
To enter literal values (e.g. text or white space that
you want to appear beside the specifiers), choose Literal
and enter the text where appropriate.

2. Check the results...

MySQL:

PHP:

3. Pick up the code to use in your application:

MySQL:

Formatting code:

PHP:

Formatting code:

This page includes sponsored links. The inclusion of these links does not imply an endorsement of the product or services provided by the sponsors.