Shorten long numbers to include K/M/B/T

后端 未结 2 1496
孤独总比滥情好
孤独总比滥情好 2020-12-14 18:30

I\'ve checked out Rails number_to_human but it\'s not exactly what i want.

I\'d like to shorten long numbers without including the full unit name:

42         


        
2条回答
  •  再見小時候
    2020-12-14 19:13

    Like this:

    number_to_human(a_number,format:'%n%u',units:{thousand:'K',million:'M',billion:'B'})
    

提交回复
热议问题