我正在使用nodejs来连接到mySql Db。使用node可以检索所有的表。以Node作为express的后端。
我有一个路由http://localhost:3000/getALL
当我使用它时,我会得到JSON格式的所有数据。但我在将mySql时间转换为JS对象时遇到了问题
[{"file_name":"150412-001070",
"date_time":"2015-07-21T13:11:55.000Z",
"polpospercent":68.95,"polnegpercent":31.05,
"Anger":6.58,
"Surprise":32.87,
"Sadness":32.87,
"Joy":4.59,
"Disgust":13.84,
"Fear":9.26,
"file_ts":"2014-04-26T22:03:00.000Z"}]我需要将file_ts转换为JS日期,并按日期进行排序。这也不是在angularjs ngTable上排序的。
发布于 2015-07-23 12:53:42
只需使用Moment.js即可
moment(date,'YYYY-MM-DD HH:mm:ss ZZ').format('MM-DD-YYYY [or whatever]');因为它是ISO标准,所以您应该能够这样做:
moment(date).format('MM-DD-YYYY [or whatever]');https://stackoverflow.com/questions/31578359
复制相似问题