Why datetime not showing properly in Editor datatables.
Why datetime not showing properly in Editor datatables.
Omniwyse
Posts: 29Questions: 11Answers: 0
these are the fields I am using in editor.
Also I have added dataTables.dateTime.min.css,dataTables.dateTime.min.js files.
fields: [ {
label: "ID :",
name: "holidayid",
type:"hidden",
data :"holidayid"
}, {
label: "Name :",
name: "description",
data :"description",
}, {
label: "Holiday Date :",
name: "holidaydate",
type:"datetime",
data :"holidaydate"
},
{
label: "Status :",
name: "status",
data : status,
type: "select",
}
]
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
And when click on Holiday Date Input field its always showing today date.
Not what date we have given.
That looks like a Unix timestamp to me. How are you reading it from the database? Given that it isn't ISO8601 you'll need to use
displayFormat
andwireFormat
as shown in this example. The Moment.js formatting tokens are detailed in their docs.Allan
Understood
But from server I am getting the holidaydate as Milliseconds.
How to give that format in wireFormat?
Currently I am giving as mentioned below but that is not correct bcoz I am getting milliseconds from back end. Please tell how to give that.
{
label: "Holiday Date :",
name: "holidaydate",
type:"datetime",
displayFormat: 'YYYY-MM-DD',
wireFormat: 'YYYY-MM-DD'
}
Please reply I am waiting for your response.
This is format I am getting holidaydate from Backend
Format : 2022-05-17 00:00:00.0
And I have added like below still facing same problem.
{
label: "Holiday Date :",
name: "holidaydate",
type:"datetime",
displayFormat: 'YYYY-MM-DD',
wireFormat: 'YYYY-MM-DD HH:mm:ss.S',
},
If you could wait at least 24 hours before bumping a post, that would be appreciated.
Could you show me a sample of the JSON that is being loaded from the server please? Initially you said it was epoch milliseconds, and now you've said it is ISO8601 - I'm not sure which it is?
Also, do you have Moment.js loaded on the page? If you could link to the page showing that issue, that would be really useful.
Allan
Sorry,
This is the JSON from backend
And Monent.min.js is loaded.
Thank you. So the wire format (what is received and what is sent) is Unix epoch time in milliseconds. From the Moment.js documentation, your wire format should therefore be
x
.Allan
Thanks,
You mean to say like below,
If yes, I have tried like this , but its not working . Same problem as earlier I could see.
I would expect that to work. As it isn't could you link to a page showing the issue so I can debug and trace it thought please.
Thanks,
Allan