you can try this :
const dateFromMysql = "2023-04-21 09:51:47.539966";
// conver the string into javascript date object
const dateObject = new Date(dateFromMysql);
// output complete date in javascript
document.getElementById("demo").innerHTML = dateObject;
// Fri Apr 21 2023 09:51:47 GMT+0000 (GMT)
and then you can chain all date methods that you want, in order to format date
dateObject.getFullYear(); //Get the year as a four digit number (yyyy)
dateObject.getMonth(); //Get the month as a number (0-11)
dateObject.getDate(); //Get the day as a number (1-31)
dateObject.getHours(); //Get the hour (0-23)
dateObject.getMinutes(); //Get the minute (0-59)
dateObject.getSeconds(); //Get the second (0-59)
dateObject.getMilliseconds() //Get the millisecond (0-999)
dateObject.getTime(); //Get the time (milliseconds since January 1, 1970)
dateObject.getDay(); //Get the weekday as a number (0-6)
dateObject.Date.now(); //Get the time. ECMAScript 5.
dateObject.setDate() //Set the day as a number (1-31)
dateObject.setFullYear() //Set the year (optionally month and day)
dateObject.setHours() //Set the hour (0-23)
dateObject.setMilliseconds() //Set the milliseconds (0-999)
dateObject.setMinutes() //Set the minutes (0-59)
dateObject.setMonth() //Set the month (0-11)
dateObject.setSeconds() //Set the seconds (0-59)
dateObject.setTime() //Set the time (milliseconds since January 1, 1970)
to get an overview visite this : https://www.w3schools.com/js/js_date_methods.asp
for more details : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date