7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angular5でDatePipeを使う。LOCALEセットしてね。

Posted at

バージョン

  • ionic 4.1.1
  • Angular 5.2.11

LOCALE設定

Angular 5 Breaking change - manually import locale - Stack Overflow

  • app.module.ts

providerにセットして、かつ、registerLocaleDataをしてやる必要がある


import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import localeJa from '@angular/common/locales/ja';
import { registerLocaleData } from '@angular/common';

registerLocaleData(localeJa);

@NgModule({
    declarations: [
        MyApp,
        HomePage
    ],
    imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp)
    ],
    bootstrap: [IonicApp],
    entryComponents: [
        MyApp,
        HomePage
    ],
    providers: [
        { provide: LOCALE_ID, useValue: 'ja-JP' },
        StatusBar,
        SplashScreen,
        { provide: ErrorHandler, useClass: IonicErrorHandler }
    ]
})
export class AppModule { }

DatePipe

Angular - DatePipe

  • html
<span class="msg-date">{{chat.send_at | date:'yyyy/MM/dd HH:mm'}}</span>
  • 表示
2018/09/03 09:20
7
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?