Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 2
    When using the javascript Date constructor, months are 0 based. So 0 is January and 1 is February. Corrected missing y Commented Feb 2, 2016 at 4:34
  • 25
    Incase it helps any one else, date pipe is imported from 'angular2/common'. Commented Feb 2, 2016 at 4:39
  • 1
    Code snippet doesn't compile.... error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'string'. on line var formatted = new DatePipe().transform(raw, ['yyyy-MM-dd']); Commented Jul 1, 2016 at 23:10
  • 10
    Now released Angular v2.0.0, and you can inject this pipe. First, add to NgModule: @NgModule({ providers:[DatePipe] }), then in your class, import and inject constructor( private datePipe: DatePipe ){} Commented Sep 28, 2016 at 0:27
  • 2
    meanwhile the Angular2 DatePipe expects the Locale_ID as constructor argument. So if you try to use it directly you would have to provide a fix Locale_ID and therefor it won't take apps Locale_ID anymore. That why I would NOT recommend to go that way. Commented Feb 17, 2017 at 10:35