Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Pipe, PipeTransform } from '@angular/core';
- import * as moment from 'moment';
- @Pipe({
- name: 'mydate'
- })
- export class MyDatePipe implements PipeTransform {
- transform(value: any, format?: string) {
- if (value === null || value === undefined) {
- return '';
- }
- if (!format) {
- format = 'YYYY/MM/DD';
- }
- const d = moment(value);
- return d.isValid() ? d.format(format) : '';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement