How Do I Fix NaN Problem With dmx-date-picker?

I have a date/time picker defined like this:

<input id="i_mt_autosend_time" class="ml-2 b_right2 rc_5 c_right7 fs_80 w_200" name="autosend_time" is="dmx-date-picker" timepicker=""
									minutes-increment="60" dmx-bind:value="message_template.data.message_template.autosend_datetime" format="ddd d MMM h mm a" utc="true">

It allows me to pick a date and time, but when I click [Apply] the values I have selected are not shown and if I try to select the dates again I get a calendar full of NaN:

nan

What am I doing wrong?

I have seen this before but could not solve it.
It has something to do with format I think.
A few days later, when I used date picker somewhere else, it worked fine with date format etc.

Try removing the attributes like format, utc, value etc in the tag and see which one makes a difference.

Hi there @sid, thanks for sharing that experience! I spent half an hour changing those tags last night and the problem only seemed to get worse.

@Teodor or @patrick, do you know what is happening here?

Probably you are using some wrong format there Antony, could be the value returned from the database in a wrong format - could be almost anyhing… Please provide a link where we can check this.

Thanks for that feedback @teodor! I’ll upload it to a server later on today.

Can you clarify what is the “right format”?

So can I only used a limited number of formatting styles in the format="ddd d MMM h mm a" field?

If I just save the value stored in the input to the datebase and retrieve it again do I need to do some formatting along the way?

Are you saying that I need to separately manage both display formatting and database save formatting?

Can you give me an example of how to sensibly use this to save and retrieve a datetime value to mySQL?

Sorry for so many questions but I’m a bit confused about what is going on here! :confused:

In your database you always store the correct datetime format, that;'s what the datepicker always sends to the serverside.
The date format in the datepicker is for the user only, how the users see the date.

As i explained i need a test link where i can check what you are doing exactly. I can’t answer your question looking at a screenshot.

Brilliant, thanks for clarifying that Teodor! I’ll send you a link when I do an upload to my test server later on today!

@Teodor found the answer… I had an incorrect character in the format string:

ddd d MMM h mm a

The single ‘d’ is not supported and should be upper case:

ddd D MMM h mm a
1 Like