Issue
I using Django-rest and I want to get month form Datefield in AngularJS.
My code is date = '2014-2-30'
and I get month: var x = (new Date (Date.parse (date).getMonth()
.
But x = 1
and value of year = 114
.
I read https://docs.angularjs.org/api/ng/filter/date but I can't do it. Would you give me example?
Solution
Django REST Framework should pass dates back to Angular in ISO 8601 format (yyyy-MM-dd
), so there shouldn't be an issue parsing it on Angular's side.
{{ obj.date | date:"MMMM" }}
MMMM
is the Angular date code for the full month (January-December
). You can find other Angular date codes in the date
filter documentation.
Answered By - Kevin Brown-Silva
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.