function strToDate(date) {
// var timeBound = str.replace(/-/g, "/");
// var timeBoundSubstr = timeBound.substring(0, 19);
// var dateBound = new Date(timeBoundSubstr);
var dateBound = date;
var GMT_bound = dateBound.getTimezoneOffset();
var dateNum = dateBound.getTime();
var connectionTimeB = dateNum - GMT_bound * 60000;
var connectionDateB = new Date(connectionTimeB);
var GMTtime = formatDateToStr(connectionDateB);
return GMTtime;
}
function formatDateToStr(date) {
var arr = [
date.getFullYear(),
"-",
date.getMonth() + 1 <= 9 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1,
"-",
date.getDate() < 9 ? "0" + date.getDate() : date.getDate(),
"-",
date.getHours() < 9 ? "0" + date.getHours() : date.getHours(),
"-",
date.getMinutes() < 9 ? "0" + date.getMinutes() : date.getMinutes(),
"-",
date.getSeconds() < 9 ? "0" + date.getSeconds() : date.getSeconds(),
];
return arr.join("");
}
//console.log(new Date(2017,11,30,11,30,20))
console.log(strToDate(new Date()))
console