84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
数据库中存的是时间戳2014-11-11 00:00:00从数据库中取出来打印row[0].startTime结果是Mon Apr 20 2015 01:49:19 GM +0800 (中国标准时间) 这种格式的res.send返给前台 变成了2014-11-11T00:00:00.000Z怎么才能返给前台正常格式的呢(2014-11-11 00:00:00)谢谢大家~~
闭关修行中......
用momentjs转换或者。。。自己转:
var format = function(date) { var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hour = date.getHours(); var minute = (date.getMinutes() < 10) ? '0' + date.getMinutes() : date.getMinutes(); //var minute = date.getMinutes(); var second = (date.getSeconds() < 10) ? '0' + date.getSeconds() : date.getSeconds(); //var second = date.getSeconds(); return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; };
根据需要是否在分和秒补零~
分
秒
可以在数据库中做处理:
SELECT DATE_FORMAT(NOW(), '%Y-%m-%d %H:%m:%S') AS startTime;
来自:http://stackoverflow.com/questions/2392413/convert-datetime-value-into...
function makeDate(date) { try { var date = new Date(date).toISOString(). replace(/T/, ' '). replace(/\..+/, ''); }catch(e){ console.log(e); var date = "0000-00-00 00:00:00"; }finally{ return date; } };
用momentjs转换或者。。。自己转:
根据需要是否在
分
和秒
补零~可以在数据库中做处理:
来自:http://stackoverflow.com/questions/2392413/convert-datetime-value-into...