--- title: "dateFormat" description: "Returns the given date as a string, formatted according to a pattern." --- # dateFormat > Returns the given date as a string, formatted according to a pattern. **This function is used by Ignition's Expression language.** ## Description Returns the given date as a string, formatted according to a pattern. The pattern is a format that is full of various placeholders that will display different parts of the date. These are case-sensitive! These placeholders can be repeated for a different effect. For example, M will give you 1-12, MM will give you 01-12, MMM will give you Jan-Dec, MMMM will give you January-December. Refer to [Data Type Formatting Reference](appendix/reference-pages/data-type-formatting-reference/data-type-formatting-reference.md) for a table of the placeholders. :::tip Expert Tip This function uses the Java class [java.text.SimpleDateFormat](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/text/SimpleDateFormat.html) internally, and will accept any valid format string for that class. ::: ## Syntax `dateFormat(date, pattern)` ### Parameters | Type | Parameter | Description | |--------|-----------|--------------------------------------------------------------| | Date | `date` | The starting date to format. | | String | `pattern` | The pattern to format the given date. | ### Returns **String** - The given date formatted according to the specified pattern. ## Examples ```python title="Code Snippet" dateFormat(toDate("2003-9-14 8:00:00"), "yyyy-MM-dd HH:mm:ss") //returns the string "2003-09-14 08:00:00" This format is accepted in most databases ``` ```python title="Code Snippet" dateFormat(toDate("2003-9-14 8:00:00"), "yyyy-MM-dd h a") //returns the string "2003-09-14 8 AM" ``` ```python title="Code Snippet" dateFormat(toDate("2003-9-14 8:00:00"), "MMM d, yyyy") //returns the string "Sep 14, 2003" ``` ```python title="Code Snippet" dateFormat(now(), 'yyyy-MM-dd 00:00:00') //returns the current date, but forces the time to 00:00:00 ```