JSFiddle - React, Tailwind, and code Playground
HTML
<input id="dateTime" type="datetime-local">
<input id="send" type="button" value="send">
JavaScript
// bad input ----------------------------------------------
const badInput = '22:01:2021 14:55 - xy';
[dd, mm, yyyy, h, m] = badInput.substring(0, badInput.length - 5).replace(' ', ':').split(':');
const dt = new Date(yyyy, mm - 1, dd, h, m);
console.log(dt.toString());
// good input ------------------------------------------------
document.getElementById('send').addEventListener('click', processDate);
function processDate() {
const dateTime = new Date(document.getElementById('dateTime').value);
console.log(dateTime.toString());
}