How do I set the Time portion of a Date/Time Field?

I ended up deleting my “date/time” field and made a dateTime field that takes “text” as input.

My solution requires you to manually insert your form into the collection. That being said I created an “onClick” event for my “Submit” button and below is the code snippet for my date and time input fields on the form.

let datePattern = /\w+\s\d+\s\d+/; //regex mumbo jumbo, w3schools , if you want to learn more
let dateResult = $w(‘#datePicker1’).value.toDateString().match(datePattern);
let timePattern = /\d+:\d+/;
let timeResult = $w(‘#timePicker1’).value.match(timePattern);
var dateTime = dateResult[0] + " , " + timeResult[0];

// dateTime will be formatted this way: Mmm DD YYYY , HH:MM (24HR time)


Hopefully this helps