There are a few methods that you can use to handle this Date object as seen below :
Creating a Prototype Function
You could create a very basic prototype function which would allow you to explicitly build a string using each of the components, which may be an excellent approach if you intend to reuse this function or similar ones often :
//Creating a Prototype
Date.prototype.yyyymmddhhmmss = function() {
//Grab each of your components
var yyyy = this.getFullYear().toString();
var MM = (this.getMonth()+1).toString();
var dd = this.getDate().toString();
var hh = this.getHours().toString();
var mm = this.getMinutes().toString();
var ss = this.getSeconds().toString();
//Returns your formatted result
return yyyy + '-' + (MM[1]?MM:"0"+MM[0]) + '-' + (dd[1]?dd:"0"+dd[0]) + ' ' + (hh[1]?hh:"0"+hh[0]) + ':' + (mm[1]?mm:"0"+mm[0]) + ':' + (ss[1]?ss:"0"+ss[0]);
};
//Usage
alert(new Date().yyyymmddhhmmss());
Example
Output as yyyy-mm-dd
Very similar to the example above, you can directly build the string using the individual components of the Date object :
//Create a Date object
var date = new Date();
//Concatenate the sections of your Date into a string ("yyyy-mm-dd")
var formatted = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
Output as yyyy-mm-dd hh:mm:ss
This method is identical to the above with the exception that it also includes a few additional fields such as hours, minutes and seconds.
var date = new Date();
var formatted = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();