db.js
/**
 * Format a JavaScript date object as an SQL DATE or DATETIME
 * @param {Date} date Input JavaScript Date object/class
 * @param {Boolean} isDATETIME Should the time be added to make the formatted date an SQL DATETIME (YYYY-MM-DD HH:MI:SS)
 */
Format a JavaScript date object as an SQL DATE or DATETIME
@param {Date} date Input JavaScript Date object/class
@param {Boolean} isDATETIME Should the time be added to make the formatted date an SQL DATETIME (YYYY-MM-DD HH:MI:SS)
Format a JavaScript date object as an SQL DATE or DATETIME @param { Date } date Input JavaScript Date object / class @param { Boolean } isDATETIME Should the time be added to make the formatted date an SQL DATETIME ( YYYY - MM - DD HH : MI : SS )
function formatDateSQL(date, isDATETIME) {
  let SQLDate = date.toISOString().slice(0, 10); 
  if (isDATETIME) SQLDate += date.toISOString().slice(10, 19).replace('T', ' '); 
  return SQLDate;
}
function formatDateSQL ( date , isDATETIME ) { let SQLDate = date . toISOString ( ) . slice ( 0 , 10 ) ; if ( isDATETIME ) SQLDate += date . toISOString ( ) . slice ( 10 , 19 ) . replace ( 'T' , ' ' ) ; return SQLDate ; }
Format a JavaScript date object as an SQL DATE or DATETIME
 @param {Date} date Input JavaScript Date object/class
 @param {Boolean} isDATETIME Should the time be added to make the formatted date an SQL DATETIME (YYYY-MM-DD HH:MI:SS)
Format a JavaScript date object as an SQL DATE or DATETIME @param { Date } date Input JavaScript Date object / class @param { Boolean } isDATETIME Should the time be added to make the formatted date an SQL DATETIME ( YYYY - MM - DD HH : MI : SS )
// YYYY-MM-DD // HH:MI:SS