1npm install --save moment
2import * as moment from 'moment';
3...
4let myMoment: moment.Moment = moment("someDate");
1npm install --save moment ngx-moment
2...
3import { MomentModule } from 'ngx-moment';
4
5@NgModule({
6 imports: [
7 MomentModule
8 ]
9})
1moment("20111031", "YYYYMMDD").fromNow(); // 9 years ago
2moment("20120620", "YYYYMMDD").fromNow(); // 8 years ago
3moment().startOf('day').fromNow(); // 13 hours ago
4moment().endOf('day').fromNow(); // in 11 hours
5moment().startOf('hour').fromNow(); // 4 minutes ago