Date.prototype.toMySQLFormat = function(bDateOnly){
	
	if(isNaN(this.getFullYear()) || isNaN(this.getMonth()) || isNaN(this.getDate()) || isNaN(this.getHours()) || isNaN(this.getMinutes())){
		return null;
	}
	
	if(typeof(bDateOnly) == "undefined"){
		bDateOnly = false;
	}
	var sFormatedString = "";
	
	sFormatedString += this.getFullYear();
	sFormatedString += "-";
	if(this.getMonth() * 1 < 9){
		sFormatedString += "0";
	}
	sFormatedString += this.getMonth() * 1 + 1;
	sFormatedString += "-";
	if(this.getDate() * 1 < 9){
		sFormatedString += "0";
	}
	sFormatedString += this.getDate();
	
	if(!bDateOnly){
		sFormatedString += " ";
		sFormatedString += this.getHours();
		sFormatedString += ":";
		sFormatedString += this.getMinutes();
	}
	return sFormatedString;
}
