正如您在编辑中指出的那样,您必须在应用程序中定义区域设置.
DatePipe状态的文档
Formats a date according to locale rules.@H_301_4@
必须像这样使用管道@H_301_4@
{{ date_expression | date[:format[:timezone[:locale]]] }}
如您所见,管道接受格式,时区和语言环境参数(除了要解析的实际日期).
阅读更多文档说明@H_301_4@
locale
is a string defining the locale to use (uses the current 07001 by default)@H_301_4@
Here’s阅读LOCALE定义的工作原理.
您可能希望用德语本地化整个应用程序.
首先,您要在AppModule中导入德语区域设置.@H_301_4@
import { registerLocaleData } from '@angular/common'; import localeDe from '@angular/common/locales/de'; registerLocaleData(localeDe);
现在您可以像往常一样使用语言环境@H_301_4@
@NgModule({ // ... providers: [{provide: LOCALE_ID,useValue: 'de'}] }) export class AppModule{}