将字符串转换为实时日期和时间

Kun*_*nok 7 javascript json

我有JSON代码:

{ "time":"2015-10-20T11:20:00+02:00" }
Run Code Online (Sandbox Code Playgroud)

我从我的脚本中读到了JSON,表中的输出是:

2015-10-20T11:20:00+02:00
Run Code Online (Sandbox Code Playgroud)

但是我希望输出等于那天和它的时间.

例如:星期二20:00(如果我的时区是+02)

Dav*_*hta 7

你可以格式化这样的日期:

var date = new Date('2015-10-20T11:20:00+02:00');
var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var output = days[date.getDay()] + ' ' + date.getHours() + ':' + date.getMinutes();
console.log(output);
// Tue 6:20
Run Code Online (Sandbox Code Playgroud)