Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Created March 15, 2023 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/485d9401c0bd41e973abfef875c8d2a8 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/485d9401c0bd41e973abfef875c8d2a8 to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';
import 'moment/locale/tr';
@Pipe({
name: 'humanReadableDate',
})
export class HumanReadableDatePipe implements PipeTransform {
transform(date: Date) {
const now = moment();
let future = moment(new Date(date));
return moment.duration(future.diff(now)).humanize(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment