3

I'm using moments js to convert from c# JSONified datetime /Date(1501287730903)/ as recommended here

$scope.var = moment($scope.var).toDate();

My objective is to turn the variable that holds /Date(1501287730903)/ not just into JS date, but a string like 05 Jan 2017

$scope.var = moment($scope.var).format('DD/MM/YYYY');

works fine, but I am wanting the actual letters of month. When I proceed to

$scope.var = moment($scope.var).format('DD/MMM/YYYY');

however, I get 28-júl-2017 and MMMM renders 29-júlí-2017

I'm not sure but it looks like it's going for Spanish months..? How can I specify English?

dras
  • 138
  • 4
  • 14
  • 1
    According to Google Translate that's Icelandic (`is-is` locale), in case you have to look for it in your code. – yuriy636 Jul 28 '17 at 21:02
  • You will get `júl` as `MMM` month name using moment 2.18.1 for [Hungarian (hu)](https://github.com/moment/moment/blob/2.18.1/locale/hu.js#L49), [Icelandic (is)](https://github.com/moment/moment/blob/2.18.1/locale/is.js#L82) and [Slovak (sk)](https://github.com/moment/moment/blob/2.18.1/locale/sk.js#L15) – VincenzoC Jul 29 '17 at 18:17

1 Answers1

5

What is the locale that you have loaded into moment? I am guessing that before this code you loaded the Spanish locale like this:

moment.locale('es-es');

Try to load the English locale before parsing the date like this:

moment.locale('en');
Avi K.
  • 1,734
  • 2
  • 18
  • 28
  • As per [this](https://stackoverflow.com/q/30842477/5671022) I tried moment.locale('en'). Avi K, I think you're right. I have no recollection of moving to spanish, but I'll check my code... – dras Jul 28 '17 at 21:05