--- title: "system.date.format" description: "Returns the given date as a string and formatted according to a pattern." --- # system.date.format > Returns the given date as a string and formatted according to a pattern. This function is used in **Python Scripting**. ## Description Returns the given date as a string and formatted according to a pattern. The pattern is a format that is full of various placeholders that 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| Tex| 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. ::: ## Client Permission Restrictions This scripting function has no [Client Permission](projects\project-properties\project-properties.md#client---permissions) restrictions. ## Syntax `system.date.format(date, format)` ### Parameters Type | Parameter | Description ------- | ------- | ------ Date | `date` | The date to format. String | `format` | A format string such as "yyyy-MM-dd HH:mm:ss". The format argument is optional. The default is "yyyy-MM-dd HH:mm:ss". Refer to Data Type Formatting Reference for a table of acceptable symbols. ### Returns **String** - A string representing the formatted datetime. ### Scope All ## Code Examples ```python title="Example #1" # This example would format the current date to look like "01/01/01" today = system.date.now() print system.date.format(today, "yy/MM/dd") #This printed 16/04/01 ``` ```python title="Example #2" # This example would format the current date to look like "2001-01-31 16:59:59" # This is a standard format that all databases recognize. today = system.date.now() print system.date.format(today, "yyyy-MM-dd HH:mm:ss") ```