import { Pipe, PipeTransform } from '@angular/core'; import * as moment from 'moment'; @Pipe({ name: 'timeElapsed', }) export class TimeElapsedPipe implements PipeTransform { transform(checkInTime: string | null): any { if (!checkInTime) return; const checkInMoment = moment(checkInTime); const now = moment(); return moment.duration(now.diff(checkInMoment)).humanize(); } }