Tutorial To Change Date Format Ng-bootstrap Datepicker Angular 5

Here’s an easy way to change the date format on the ng-bootstrap datepicker angular 5. I got this way via ng-bootstrap official github and I have tested its success. If you use the ng-bootstrap module to run the css bootstrap framework component without jQuery, there are few constraints such as changing the date format according to the format you need. Ng-bootstrap implements ISO 8601 for date format. Follow this short tutorial

Read more: Tutorial Simple CRUD Angular 5 And Lumen 5.6 For Beginners

Change Date Format Ng Bootstrap Datepicker

On the ng-bootstrap official site, datepicker has yyyy-mm-dd format, to change to “dd/mm/yyyy” you need to create a new class to extend the NgbDateParserFormatter class .

Create a new ts file named dateformat.ts and copy the following code

then import the class on the angular component that is using the datepicker.

Then add the provider to the component that will use the class

Please run your application and test the result. If successful then the application goes like the following picture

Tutorial Change Date Format Datepicker Ng Bootstrap Angular 5

Source code: https://github.com/ng-bootstrap/ng-bootstrap/issues/2072

Read another article:Angular 4 Tutorial For Beginner With Simple App Project

So a quick tutorial on how to change the date format on ng-bootstrap datepicker angular 5.

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.