13 lines
354 B
TypeScript
13 lines
354 B
TypeScript
import { Pipe, PipeTransform } from '@angular/core';
|
|
import * as moment from 'moment';
|
|
|
|
@Pipe({ name: 'datef' })
|
|
export class MomentPipe implements PipeTransform {
|
|
transform(value: Date | moment.Moment, dateFormat: string): any {
|
|
if (!dateFormat) {
|
|
return moment(value).fromNow();
|
|
}
|
|
|
|
return moment(value).format(dateFormat);
|
|
}
|
|
} |