DateTime in a format that I can upload to MS Sql Server
function getSQLDate() {
var dt = new Date();
var dtstring = dt.getFullYear()
+ '-' + pad(dt.getMonth() + 1, 2)
+ '-' + pad(dt.getDate(), 2);
return dtstring;
}
The above function provides me Date in a format that I can upload to MS Sql Server. But this succeeds only
for the date part. If I extend the function (as below) to include "time", the data is not saved.
function getSQLDate() {
var dt = new Date();
var dtstring = dt.getFullYear()
+ '-' + pad(dt.getMonth() + 1, 2)
+ '-' + pad(dt.getDate(), 2)
+ ' ' + pad(dt.getHours(), 2)
+ ':' + pad(dt.getMinutes(), 2)
+ ':' + pad(dt.getSeconds(), 2);
return dtstring;
}
Can someone please help me in getting the properly formatted "datetime" from a javascript/jquery function?
TIA