Skip to content

Instantly share code, notes, and snippets.

@yoelnacho
Created July 16, 2017 21:35
Show Gist options
  • Select an option

  • Save yoelnacho/80519e84ed7c6a784377e2245dd512a4 to your computer and use it in GitHub Desktop.

Select an option

Save yoelnacho/80519e84ed7c6a784377e2245dd512a4 to your computer and use it in GitHub Desktop.
moment pipe
import { Pipe, PipeTransform } from '@angular/core';
import moment from 'moment';
@Pipe({
name: 'moment'
})
export class MomentPipe implements PipeTransform {
transform(value: moment.Moment, format: string) {
if (!moment.isMoment(value))
value = moment(value);
return value.format(format);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment