Created
July 16, 2017 21:35
-
-
Save yoelnacho/80519e84ed7c6a784377e2245dd512a4 to your computer and use it in GitHub Desktop.
moment pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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