Setting the bs locale in Angular 2’s DatePipe

Feedback


Solution 1:

Hi can you look at this post

set locale in datepipe

I believe the post mentioned above is functioning properly. Could you please verify it?


Solution 2:

in your module module

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LOCALE_ID } from '@angular/core';
import { AppComponent }   from './app.component';
@NgModule({
 imports:      [ BrowserModule ],
 declarations: [ AppComponent ],
 bootstrap:    [ AppComponent ],
 providers: [
    { provide: LOCALE_ID, useValue: 'bs-BA' },
],
})
export class AppModule { }

in your component

import { Component } from '@angular/core';
@Component({
 selector: 'my-app',
  template: `
  {{date | date: 'd MMMM y'}}
 `
 })
 export class AppComponent {
    date = new Date(1988, 2, 15);
 }

This for "bs-BA"

This for "en-US"

Frequently Asked Questions