5

I am using this for date formatting at the moment:

var format = moment().localeData(locale).longDateFormat("L");
return moment(dateObj).format(format);

Where locale can be any market eg. en-US, fr-FR, en-GB etc...

However, the L date format has the MM/DD/YYYY (it changes per market, of course) and I just want MM/DD. I didn't find any format that provides this kind of string. Does anyone know how I can achieve the desired functionality?

user648931
  • 503
  • 5
  • 18

1 Answers1

-1

It might be a bit more hacky than you're looking for, but....

var format = moment().localeData('en').longDateFormat("L");
moment().format(format).substr(0,moment().format(format).length-5);
Wes Tyler
  • 140
  • 1
  • 11
  • 1
    the year doesn't always go in the same spot - could be in the beginning or the end. Found this later, that seems to work for all the locales defined in moment, although i haven't done an exhaustive check: http://stackoverflow.com/questions/27360102/locale-and-specific-date-format-with-moment-js – user648931 Aug 28 '15 at 00:11