If this is a Types date field then the value will be stored as a timestamp (number of seconds since 1 Jan 1970).
Your ajax call triggers some PHP code on the server that returns the value.
You can either have the PHP code return a formatted value (you could use types_render_field to give the formatted value, the same as outputting the field with a types shortcode, or you could take the raw timestamp and produce the formatted string using the PHP date function).
Or your ajax request could receive the unformatted timestamp and use JavaScript to format that data as required.
hidden link
That may be the better option because if you have a Types date field in a form that includes a hidden input with the timestamp that will be stored and a visible text field that contains the formatted date string.
(You can inspect your form in the front-end with the browser dev tools to see how that works.)
The topic ‘[Closed] Update the form field after an ajax call’ is closed to new replies.