I\'m trying to use javascript to convert a date object into a valid mysql date - what is the best way to do this?
just this :
Object.defineProperties( Date.prototype ,{
date:{
get:function(){return this.toISOString().split('T')[0];}
},
time:{
get:function(){return this.toTimeString().match(/\d{2}:\d{2}:\d{2}/)[0];}
},
datetime:{
get : function(){return this.date+" "+this.time}
}
});
now you can use
sql_query = "...." + (new Date).datetime + "....";