Date format helper

This utility helps you build date format strings. It produces output compatible with date formatting functions for Java, MySQL and PHP. The utility shows you the date format string as well a code sample for the chosen platform.

Loading utility...

Using the date format helper

On the "Predefined date formats" tab (this is the only option available on small-screen devices), you can select a predefined date/time format from a list of common variations. Choose the compatibility (either Java, MySQL or PHP) and one of the predefined formats and the utility will show you the formatting string to use and a code sample.

If the format you require is not in the list then you can use the custom format string builder described below.

On the "Build custom date format" tab, create a sample date/time in the format you require by dragging elements into the dotted box. The draggable elements represent fragments of a date that can be arranged in the required manner. The sample date chosen is 1:00am on the 1st January 1970 but this is just a dummy date for expressing the date/time style you require.

When you have built your sample date/time in the style you would like it to appear choose the compatibility (either Java, MySQL or PHP) and click the "Generate format string" button. The utility will show you the formatting string to use and a code sample.

Look at the example below where elements have been dragged in to the box to show a date style that looks like "Thursday, 1st January, 1970". The generated format string can then be used to format any input date/time in the same style:

Date format example

Note the space characters have been explicitly added. Spaces are not added automatically (you might not want them) so you must add them yourself where they are required.

For more information on the Java SimpleDateFormat#format method see the Javadoc page. For the PHP date function see the manual entry. For the MySQL DATE_FORMAT function take a look at the manual page for date and time functions.

ADVERTISEMENT
Predefined date formatsBuild custom date format
Drag the boxes below into the dotted area to build an example of the required format
  • |Thu|
  • |Thursday|
  • |01|
  • |1|
  • |1st|
  • |01|
  • |1|
  • |Jan|
  • |January|
  • |1970|
  • |70|
  • |1|12hr
  • |01|12hr
  • |1|24hr
  • |01|24hr
  • |00|
  • |00|
  • |AM|
  • | |
  • |/|
  • |:|
  • |-|
  • |_|
  • |,|
  • |.|
  • |'|