File

src/app/shared/pipes/relative-date.pipe.ts

Metadata

Name relativeDate

Methods

transform
transform(value: any)
Parameters :
Name Type Optional
value any No
Returns : any
import { Pipe, PipeTransform } from '@angular/core';

import * as moment from 'moment';

@Pipe({
  name: 'relativeDate'
})
export class RelativeDatePipe implements PipeTransform {
  constructor() {}

  transform(value: any): any {
    if (!value) {
      return 'unknown';
    }
    return moment(value * 1000).fromNow();
  }
}

result-matching ""

    No results matching ""