stn.js
function (d, use_UTC) {
		if (typeof d === "string") {
			if (d.match(/[0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9]/)) {
				return d.replace(/\s+/, "");
			}
			d = new Date(d);
		} else if (typeof d === "number") {
			d = new Date(d);
		} else if (typeof d !== "object" &&
				typeof d.getFullYear !== "function") {
			throw "Expecting type: " + String(d) + " --> " + typeof d;
		}
		if (!use_UTC) {
			return [
				d.getFullYear(),
				String("0" + (d.getMonth() + 1)).substr(-2),
				String("0" + d.getDate()).substr(-2)
			].join("-");
		}
		return [
			d.getUTCFullYear(),
			String("0" + (d.getUTCMonth() + 1)).substr(-2),
			String("0" + d.getUTCDate()).substr(-2)
		].join("-");
	}
function (d, use_UTC) {
		if (typeof d === "string") {
			if (d.match(/[0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9]/)) {
				return d.replace(/\s+/, "");
			}
			d = new Date(d);
		} else if (typeof d === "number") {
			d = new Date(d);
		} else if (typeof d !== "object" &&
				typeof d.getFullYear !== "function") {
			throw "Expecting type: " + String(d) + " --> " + typeof d;
		}
		if (!use_UTC) {
			return [
				d.getFullYear(),
				String("0" + (d.getMonth() + 1)).substr(-2),
				String("0" + d.getDate()).substr(-2)
			].join("-");
		}
		return [
			d.getUTCFullYear(),
			String("0" + (d.getUTCMonth() + 1)).substr(-2),
			String("0" + d.getUTCDate()).substr(-2)
		].join("-");
	}
function ( d , use_UTC ) { if ( typeof d === "string" ) { if ( d . match ( / [0-9][0-9][0-9][0-9][\s]*-[0-1][0-9]-[\s]*[0-3][0-9] / ) ) { return d . replace ( / \s+ / , "" ) ; } d = new Date ( d ) ; } else if ( typeof d === "number" ) { d = new Date ( d ) ; } else if ( typeof d !== "object" && typeof d . getFullYear !== "function" ) { throw "Expecting type: " + String ( d ) + " --> " + typeof d ; } if ( ! use_UTC ) { return [ d . getFullYear ( ) , String ( "0" + ( d . getMonth ( ) + 1 ) ) . substr ( - 2 ) , String ( "0" + d . getDate ( ) ) . substr ( - 2 ) ] . join ( "-" ) ; } return [ d . getUTCFullYear ( ) , String ( "0" + ( d . getUTCMonth ( ) + 1 ) ) . substr ( - 2 ) , String ( "0" + d . getUTCDate ( ) ) . substr ( - 2 ) ] . join ( "-" ) ; }
Format a date as YYYY-MM-DD @param Date object @return string in YYYY-MM-DD format
Format a date as YYYY - MM - DD