如何格式化要打印的JavaScript日期对象10-Aug-2010?
我想在angular2项目中实现moment.js库我命令将UTC时间转换为某个时区Europe/london并且使用moment和[moment timezone] 1
到目前为止,我已moment.js使用以下命令安装在我的Angular2项目中:
npm安装时刻--save
这是我目前的代码:
import { Component, Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';
@Pipe({ name: 'moment' })
class MomentPipe{
transform(date, format) {
return moment(date).format(format);
}
}
Run Code Online (Sandbox Code Playgroud)
Html:
我从后端收到了作为对象的时间
//time.bookingTime.iso == 2016-07-20T21:00:00.000Z
{{time.bookingTime.iso | moment}}
Run Code Online (Sandbox Code Playgroud)
它对我不起作用,我认为我的实施错误