DynaPDF.SetDateTimeFormat
-------------------------

Sets field to use date format.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [12.3](newinversion123.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetDateTimeFormat"; PDF; Field; DateFormat ) 

**MBS**( **"DynaPDF.SetDateTimeFormat";** /\* Sets field to use date format. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Field**; /\* The field index or field name.e.g. "Birthday" \*/   
**$DateFormat**) /\* The new date format.e.g. "MM\_DD\_YY" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Field | The field index or field name. | "Birthday" |
| DateFormat | The new date format. | "MM\_DD\_YY" |

### Result

Returns OK or error.

### Description

Sets field to use date format.  
The function restricts the allowed value of a text field to a date time format and applies this format if the value was valid. A date time format is represented as two separate JavaScript actions in PDF which are automatically created and added to the text field by this function.   
The same formats can also be applied manually by creating two JavaScript actions, one for the OnKeyStroke event, and one for the OnFormat event of the text field. See [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md) for a description of the events.   
DynaPDF uses the [JavaScript](component_JavaScript.md) functions AFDate\_Keystroke() / AFDate\_KeystrokeEx() and AFDate\_Format() / AFDate\_FormatEx() to apply a date time format. The functions are described in the JavaScript scripting reference which is available at http://www.adobe.com.   
  
Format can be one of: MM\_D, M\_D\_YY, MM\_DD\_YY, MM\_YY, D\_MMM, D\_MMM\_YY, DD\_MMM\_YY, YY\_MM\_DD, MMM\_YY, MMMM\_YY, MMM\_D\_YYYY, MMMM\_D\_YYYY, M\_D\_YY\_H\_MM\_TT, M\_D\_YY\_HH\_MM, 24HR\_MM, 12HR\_MM, 24HR\_MM\_SS, 12HR\_MM\_SS,.  
See also [SetDateTimeFormat](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetDateTimeFormat.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md)
- [DynaPDF.CreateListBox](DynaPDFCreateListBox.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetPageFormat](DynaPDFSetPageFormat.md)

### Release notes

- **Version 12.3**
    - Added [DynaPDF.SetDateTimeFormat](https://www.mbsplugins.eu/DynaPDFSetDateTimeFormat.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin 12.3](https://www.mbsplugins.de/archive/2022-07-19/MBS_FileMaker_Plugin_123/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.3pr3](https://www.mbsplugins.de/archive/2022-06-13/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 9th June 2022 , last changed 9th June 2022

  
[DynaPDF.SetContent](DynaPDFSetContent.md) - [DynaPDF.SetDocInfo](DynaPDFSetDocInfo.md)

[HTML Version](DynaPDFSetDateTimeFormat.shtml)