--- 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. The placeholders are: | Symbol | Description | Presentation | Examples | Other notes | |---|---|---|---|---| | G | Era designator | Text | G=AD | | | y |Year | Year | yyyy=1996; yy=96 | Lowercase y is the most commonly used year symbol | | Y | Week year | Year | YYYY=2009; YY=09 | Capital Y gives the year based on weeks (ie. changes to the new year up to a week early) | | M | Month in year | Month | MMMM=July; MMM=Jul; MM=07 | | | w | Week in year | Number | 27 | If Dec31 is mid-week, it will be in week 1 of the next year | | W | Week in month | Number | 2 | | | D | Day in year | Number | 189 | | | d | Day in month | Number | 10 | | | F | Day of week in month | Number | 2 | 2nd Sunday of the month | | E | Day name in week | Text | EEEE=Tuesday; E=Tue | | | u | Day number of week | Number | 1 | (1 = Monday, ..., 7 = Sunday) | | a | Am/Pm marker | Text | PM | | | H | Hour in day (0-23) | Number | 0 | | | h | Hour in am/pm (1-12) | Number | 12 | | | k | Hour in day (1-24) | Number | 24 | | | K | Hour in am/pm (0-11) | Number | 0 | | | m | Minute in hour | Number | 30 | | | s | Second in minute | Number | 55 | | | S | Millisecond | Number | 978 | | | z | Time zone | General time zone | zzzz=Pacific Standard Time; z=PST | | | Z | Time zone | RFC 822 time zone | Z=-0800 | | | X | Time zone | ISO 8601 time zone | X=-08; XX=-0800; XXX=-08:00 | | :::tip Expert Tip This function uses the Java class [java.text.SimpleDateFormat](http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html) internally, and will accept any valid format string for that class. ::: ## Syntax `dateFormat(date, pattern)` - Parameter Date **date** - The starting date. string **pattern** - The pattern to format the given date to. - Results - string - The given date formatted based on the given format 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 ```