Convert month "1" to "January" using date filter not working


#1

I’m simply trying to apply the date filter http://docs.angularjs.org/api/ng/filter/date to get the name of the month based on it’s integer equivalent. However its not returning a proper date or format.

I’m aware that I can create an array of month names and do it manually that way, but I’d prefer to use the built in date filter.

I’d expect the following to return January, but instead it returns Dec 31, 1969

{{ 1 | date: MMMM }}

#2

Should be javascript Date like $scope.mDate = new Date();
and {{mDate | date: ‘MMMM’}}


#3

Right, but if i pass it a single integer of any number, i’d like to get the month name. I don’t want today’s date.


#4

I don’t see the point to have Date object and not String array (you can use angular-locale, it have the array “MONTH”) if you don’t have use of date manipulation or calculation.
But if you want to, just have an array of Date like $scope.mDates= [new Date(2014,1,0), new Date(2014,1,1), …]


#5

Maybe I’m misunderstanding what a date filter should do and it’s a limitation on the implementation. I come from a different programming background that any date filter/function I ran into handled everything (including my current case)

I would assume if you say you want the format of “month name” and you pass it a single digit; it would have the basic feature to do such.

Anyways it’s no big deal, i’ll struggle through this project and choose a better framework on the next one. Seems like angular is in it’s infancy along with ionic.


#6

It’s more likely an issue with how awful date handling is in general in javascript, unless I’m missing what you’re saying. If you want sane date-manipulation in any javascript project, check momentjs: http://momentjs.com/


#7

so I’m trying to implement the moment.js library but under the ionic/angular framework it’s not working. I’m assuming there’s a good bit of programming to get this working in the view but I have no idea how to make it accessible with databinding {{value}}