Let's follow the steps to add date localization to our blog posts so that they will display in the format our readers would expect:
- We'll start by adding a simple date object to our /src/app/posts/post/post.component.ts component:
postDate = new Date();
- This will set the blog post date to the current time, which is good enough for this recipe. We can now use that date property in our template and pipe it into Angular's built-in date formatter:
<small class="pull-left">Posted - {{ postDate | date:'shortDate' }}</small>
- This will display the current date for us in a shortened format, such as 2/13/17. Next, we will need to provide a LOCALE_ID for Angular to have available to localize content for us. Let's extend our /src/i18n-providers.ts ...