问题
I'm trying to display a date using the date action, but it's giving odd output.
{{ mydate | date:'mm/dd/yyyy' }}
The month seems to be inconsistent and incorrect. What's wrong here?
回答1:
You need to use MM to display the month:
{{ mydate | date:'MM/dd/yyyy' }}
From the documentation
'MM': Month in year, padded (01-12)
...
'mm': Minute in hour, padded (00-59)
回答2:
You need to use date:'MM/dd/yyy'
mm is for minutes, MM is for months
来源:https://stackoverflow.com/questions/27584890/angular-date-parsing-unexpected-output