Skip to content

Instantly share code, notes, and snippets.

@goranprijic
Created February 22, 2017 09:28
Show Gist options
  • Save goranprijic/e25a7f0c16075d7ab759d65e4afd794a to your computer and use it in GitHub Desktop.
Save goranprijic/e25a7f0c16075d7ab759d65e4afd794a to your computer and use it in GitHub Desktop.
Using local timezone in angular2 date pipe
import { PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
import { CONFIG_LOCAL_TIMEZONE_SHIFT } from './../../environment';
export class LocalDatePipe extends DatePipe implements PipeTransform {
transform(value: any, pattern: string = 'mediumDate'): string {
return super.transform(value + CONFIG_LOCAL_TIMEZONE_SHIFT, pattern);
}
}
@YassinRekikVeolia
Copy link

YassinRekikVeolia commented Jun 5, 2018

Hy ! May i ask you how to use this Date Pipe ?
What are the CONFIG_LOCAL_TIMEZONE_SHIFT value ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment