Files
openaccounting-web/src/app/shared/datetz.pipe.ts

14 lines
437 B
TypeScript
Raw Normal View History

2019-06-27 14:11:05 -04:00
import { Pipe, PipeTransform } from '@angular/core';
2019-06-27 16:42:13 -04:00
import * as moment from 'moment-timezone/builds/moment-timezone-with-data-2012-2022.min';
//import * as moment from 'moment-timezone';
2019-06-27 14:11:05 -04:00
@Pipe({name: 'datetz'})
export class DateTzPipe implements PipeTransform {
constructor() {
}
transform(date: Date, format: string, tz: string): string {
let m = moment(date).tz(tz || moment.tz.guess());
return m.format(format);
}
}