i tried that in the first text box - its not working <input id="text1" name="text1" type="text" class="form-control" is="dmx-date-picker" showdropdowns="true" dmx-bind:value="sc_test_data.data.query[0].dob.formatDate('yyyy-MM-dd')">
so, i just tried to perform a date format on the server side and then populate the textbox...that seemed to work.
So when i used the formatter on the client side, it didn't display, but when it was formatted in the server, it shows the date and the date picker. Is there a difference between the formatters?
Surely the formatDate() formatter is expecting an ISO date?
@BWCWeb can you confirm if it is dd MM yyyy or MM dd yyyy ?
Dates before the 12th day are ambiguous as a result. I can throw a custom formatter together to convert the date to ISO, given a specific source format
<script>
dmx.Formatter('string', 'datetoiso', function datetoiso(dateStr, format, separator) {
const parts = dateStr.split(separator);
// Map parts based on format order
const formatMap = {
D: 'day',
M: 'month',
Y: 'year'
};
let dateParts = {};
for (let i = 0; i < format.length; i++) {
dateParts[formatMap[format[i]]] = parts[i].padStart(2, '0');
}
// Construct ISO date
const isoDate = `${dateParts.year}-${dateParts.month}-${dateParts.day}`;
// Validate and return ISO date
return isNaN(Date.parse(isoDate)) ? 'Invalid Date' : isoDate;
})
</script>
and use sc_test_data.data.query[0].dob.datetoiso('DMY','-')
or sc_test_data.data.query[0].dob.datetoiso('MDY','-')