Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
angular2 date pipe locale_id period

I have a problem with the angular2 date pipe when using danish locale.

When I format a date like:

{{myDate | date:'dd-MM-yyyy'}} 

it outputs the day of the date with a suffixed period like this:

17.-03-2017

allthough I would expect it to be like this:

17-03-2017

The locale is set in the app.module like this:

providers: [ {provide: LOCALE_ID, useValue: 'da-DK'} ]  

I have made this plnkr to make it more clear http://plnkr.co/edit/A5ddrKP5cmsSZ9bTqzPh

UPDATE

It probably has something to do with the way dates are formatted in danish. Se below:

var locale = 'da-DK'; 
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; 
var date = new Date(2017,2,17); var result = new Intl.DateTimeFormat(locale, options).format(date); 
alert(result); 

turns into --> fredag den 17. marts 2017

Notice the dot

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

localization is "platform independent", ECMAscript provides specifications and each Javascript engine provides its own implementation.

There is also a compatibility implementation, Intl.js, which will provide the API if it doesn't already exist. You can see the implementation for the locale Danish (Denmark) here, you will see the available formats, and the day always returns the period after.

 "availableFormats": {
                "d": "d.",
                "E": "ccc",
                "Ed": "E 'den' d.",
                "Ehm": "E h.mm a",
                "EHm": "E HH.mm",
                "Ehms": "E h.mm.ss a",
                "EHms": "E HH.mm.ss",
                "Gy": "y G",
                "GyMMM": "MMM y G",
                "GyMMMd": "d. MMM y G",

You could create a custom pipe, and chain it to remove the period

{{myDate | date:'dd-MM-yyyy'|removePeriod}}

@Pipe({name: 'removePeriod'})
    export class RemovePeriodPipe implements PipeTransform {
      transform(input: string) {
        return input.replace(/\./g, '');
      }
    }
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda