# Javascript: DateFormField.getDateFormat Method

> Gets the date's format. For a certain DateFormField the format string should be one of the strings returned through the getSupportedDateFormats function. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this date's format is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: DateFormField.getDateFormat Method
- **455 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/dateformfield/getdateformat-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/dateformfield/getdateformat-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/dateformfield/getdateformat-method/llms-full.txt

---

### Description

Gets the date's format. For a certain DateFormField the format string should be one of the strings returned through the getSupportedDateFormats function. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this date's format is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.

### Syntax

```javascript
<void> DateFormField.getDateFormat(<RequestStringCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the date's format. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `DateFormField.getDateFormat` in a practical document-editing workflow. It gets the date's format. For a certain DateFormField the format string should be one of the strings returned through the getSupportedDateFormats function. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this date's format is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function inspectDateFormat(dateFormField) {
    dateFormField.getDateFormat(
        function(result) {
            console.log("get date format result:", result);
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [Javascript: DateFormField.getDate Method](https://docs.textcontrol.com/ds-server/reference/javascript/dateformfield/getdate-method/llms-full.txt)
- **Next:** [Javascript: DateFormField.getEmptyWidth Method](https://docs.textcontrol.com/ds-server/reference/javascript/dateformfield/getemptywidth-method/llms-full.txt)
