stephanec
stephanec

Reputation: 325

Add day(s) after number with moment.js

I use moment.js and I just want to add the word "day(s)" after a number. Ex:

Moment(3).function('dd') // 3 days

Any ideas?

Upvotes: 0

Views: 225

Answers (1)

Cᴏʀʏ
Cᴏʀʏ

Reputation: 107536

You can use format() with some character escaping:

moment(3).format('d [day(s)]'); // 3 day(s)

alert(moment(3).format('d [day(s)]')); // 3 day(s)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>

Upvotes: 1

Related Questions