What is the best way to convert local datetime to mysql datetime ?
example :
const date1 = new Date(1658483664000);
console.log(date1);
output :
Fri Jul 22 2022 16:54:24 GMT 0700 (WIB) // Get My Local Datetime
How do I turn it into mysql datetime :
2022-07-22 16:54:24
Thank You
CodePudding user response:
const date1 = new Date(1658483664000);
var date =moment(date1 ).format('MM-DD-YYYY HH:mm:ss');
to use this code you need to include moment.js in your project https://momentjs.com
CodePudding user response:
console.log(date1.toISOString().slice(0, 19).replace('T', ' '))