Wednesday, 14 August 2013

Javascript get current DateTime in SQL format

 function getCurrentDateTime(){  
  var currentdate = new Date();  
  //format: "2013-08-02T18:00:00B"  
  //Iso Zone: B  
  var datetime = "" + currentdate.getFullYear() + "-" + (currentdate.getMonth() + 1) + "-" + currentdate.getDate() + "T" + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds() + "B";  
  return datetime;  
 }  

No comments: