App using Angular 4 and bootstrap. I am using an input field that gets the date with month and year (type=month). But when the date saves, I am seeing "yyyy-mm" order. That is fine, but how can I switch the order in the client view to show mm-yyyy or even January 2018?
1 Answer
You would use the date pipe structure:
{{ dateExpression | date: 'mm-dd-yyyy' }}
There is a good short page about it here that you can read and expand on.
3 Comments
Kenzo
The problem with those formats is that It is prefilling in a dd field. So when my month input is "2014-03" , the pipe converts it to 2-28-2014. Is there one that is just for MM/yyyy?
rrd
If that's the case you should look into using a 3rd party package like Angular Material which has a datepicker. There's a few others too, lots of which are highly configurable and will probably fit the bill you're looking for: material.angular.io/components/datepicker/overview
Parth Savadiya
you can try like: {{ dateExpression | date: 'MMM-yyyy' }}
moment(myDate).format('MMMM-YYYY');