What is a date format string?
A date format string is a pattern made up of special tokens that tell a programming language how to parse or display a date and time. For example, 'dd/MM/yyyy' in Java produces '31/12/2024'. Each token corresponds to a date component like day, month, year, hour, or minute. See also our Time Zone Difference Calculator.
Are the format tokens the same across Java, PHP, Python, and MySQL?
No — each language or platform uses its own set of tokens. Java's SimpleDateFormat uses 'dd/MM/yyyy', while PHP's date() function uses 'd/m/Y', Python's strftime() uses '%d/%m/%Y', and MySQL's DATE_FORMAT() uses '%d/%m/%Y'. This generator produces the correct tokens automatically for your chosen platform.
How do I use the generated format string in PHP?
In PHP you pass the format string to the date() function: date('d/m/Y', time()). If you have a DateTime object, use $date->format('d/m/Y'). The generated code snippet shows you the exact call to use.
How do I use the format string in Java?
Use SimpleDateFormat in older Java code: new SimpleDateFormat('dd/MM/yyyy').format(new Date()). For modern Java (8+), use DateTimeFormatter: DateTimeFormatter.ofPattern('dd/MM/yyyy').format(LocalDate.now()). The code snippet shows the modern DateTimeFormatter approach.
What is the difference between 4-digit and 2-digit year tokens?
A 4-digit year (e.g. yyyy / Y / %Y) renders the full year like '2024', while a 2-digit year (yy / y / %y) renders only the last two digits like '24'. 4-digit years are recommended for unambiguous storage and interchange.
How do I include the time in my format string?
Select either 'HH:MM' or 'HH:MM:SS' in the Include Time field, then choose 24-hour or 12-hour format. The generator appends the correct time tokens to your date format string and shows a combined example like '31/12/2024 23:59:59'.
Which date order should I use for database storage?
For database storage, YYYY-MM-DD (ISO 8601, year-month-day with hyphens) is strongly recommended. It is universally sortable, unambiguous across locales, and required by MySQL's native DATE type. Use locale-specific formats like DD/MM/YYYY only for display purposes.