Skip to content
Go to file
Cannot retrieve contributors at this time
27 lines (22 sloc) 1.08 KB
title version signature
moment.duration().locale(); moment.duration().locale(String);

You can get or set the locale of a duration using locale(...). The locale will affect the duration's string methods, like humanize(). See the intl section for more information on internationalization generally.

moment.duration(1, "minutes").locale("en").humanize(); // a minute
moment.duration(1, "minutes").locale("fr").humanize(); // une minute
moment.duration(1, "minutes").locale("es").humanize(); // un minuto

Suffixes in humanize() are also internationalized:

moment.duration(1, "minutes").locale("en").humanize(true); // in a minute
moment.duration(1, "minutes").locale("fr").humanize(true); // dans une minute
moment.duration(1, "minutes").locale("es").humanize(true); // en un minuto

moment.duration(-1, "minutes").locale("en").humanize(true); // a minute ago
moment.duration(-1, "minutes").locale("fr").humanize(true); // il y a une minute
moment.duration(-1, "minutes").locale("es").humanize(true); // hace un minuto
You can’t perform that action at this time.