Convert Large Numbers Into Words – digit.js

Category: Javascript | July 8, 2024
Author:hnasheralneam
Views Total:8 views
Official Page:Go to website
Last Update:July 8, 2024
License:MIT

Preview:

Convert Large Numbers Into Words – digit.js

Description:

digit.js is a JavaScript library that converts large numbers (larger than 6 digits) into human-readable words (like 2.1 Million, 5.0 B, etc).

It supports numbers up to Quattuorvigintillions and also has the ability to format numbers with commas as thousands separators.

See Also:

How to use it:

1. Download and load the digit.js library.

<script src="main.js"></script>

2. Convert numbers into words.

// 2.1 Million
toWord(2100000);
// 2.1 M
toWord(2100000, "short");

3. Format numbers with commas as thousands separators.

// 2,100,000
commas(2100000);

4. digit.js now supports date & time formatting since v0.3.0.

// 08/7/24
formatDate(new Date(), "dmy")
// 01:50
formatTime(new Date())

Changelog:

v0.3.0 (07/08/2024)

  • Fixed missing preceding zero for formatTime function with 12 hour time option enabled
  • Changed timeIs function to formatTime and dateIs to formatDate, but the old names are still enabled
  • Add formatTimeAmount

v0.2.1 (06/24/2023)

  • Numbers under one million in toWord can now preserve decimal precision up to three points.

v0.2.0 (03/31/2023)

  • there’s 3x as much code!
  • it can now handle large numbers up to Novemvigintillion!
  • there’s date and time formatting!
  • Date formatting in mdy and dmy
  • Time in 12 or 24 hour
  • The time between two dates, or one date and the present

You Might Be Interested In:


Leave a Reply