Buy Now
Sign in

How to change a datesyntax in a form

hyperful , February 09 at 09:42
H
hyperful
Hi there,
I have a question regarding dynamic data.
let's say you have a value in your database of a date in syntax: YYYYMMDD
Is it possible, when you load the value via dynamic data, you change something on the syntax, that for example you can show it DD-MM-YYYY or DDMMYYYY
Thanks in advance!
GreyHead
Hi hyperful,
You can do this using a Custom Code action before the HTML Render Form action. See this StackOverFlow answer for some ways to do this e.g. something like this:
<?php​
​$form->data['date'] = date('d M Y', strtotime($form->data['date']));​
​?>
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much