function data_string(str) { var d = eval('new ' + str.substr(1, str.length - 2)); console.log(d); return formatDate(d); } function formatDate(now) { var year = now.getFullYear(); var month = now.getMonth() + 1; var date = now.getDate(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; }
调用data_string方法