[help needed] I'm not able to convert text to date using javascript

Hello bubblers,

I want to ask , I have html eleemnt for which i have mentioned below javascript code

below is the fucntion where i send text value to editor.

Then I’m running another javascript code to convert text to date format.

But somehow this function returns me empty value.
What is that I’m missing on? Can someone help me with this?

any reason why the function is set to asynchronous?

Are you sure the text value is a valid value for the Date constructor?

@dorilama
No.
I’m not sure about text value. I’m getting time let’s say 12:30.
And i want to add an hr or minutes to that so, I was converting that text value to Date.
Does it require whole date and time?

always make sure that the input conforms to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ)

@dorilama
Then how can I generate this by just having time value?

A Date in javascript represents a single moment in time, not an hour.

What exactly are you trying to accomplish?

Well, when user selects start time for the session I want to calculate that end time will be 1hr by default but , if user chnages the end time value then will use that chnages value.
So basiclaly i want ot perform adding hours to the value .

the session should have a date as well, and you can use it with the hour to create a Date

@dorilama
I also have this date time picker.

For which i tried the same thing,

.
So to javascript the text value is getting properly. Check below screenshot.

after javascript when we try to set its value to custom state of type date then it gives error and still it is showing me that custom state value empty.

What is wrong over here?

From the error message it looks like you want to assign a text value to a state of type date. And you are actually converting a date to a string when you assign the value to the element.

If you are working extensively with custom html elements and custom code you should consider creating a custom plugin.
The way you are working is extremely time consuming and a big pain to debug, a match that I think is not sane to have.

Cheers

Mariano