Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Space in number format

How do I add space as a decimal number separator? The current format is 23456.00 but it has to be 23 456

I got it to remove the .00 with toFixed already but no luck with the space separator.

{{parseFloat(post.meta.price).toFixed(0)}}

Perhaps I can change the locale format in the code to fr-FR because that will add the space?

like image 275
SourceS Avatar asked Dec 31 '22 20:12

SourceS


1 Answers

Perhaps I can change the locale format in the code to fr-FR because that will add the space?

Yes, you can!

price = 23456.00
disp = new Intl.NumberFormat('fr-FR').format(price)
console.log(disp)

reference: Intl.NumberFormat

like image 174
georg Avatar answered Jan 08 '23 01:01

georg