This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// # first add script num2persian from https://www.npmjs.com/package/num2persian | |
// using from global funtion | |
console.log(Num2persian(1398)); // یک هزار و سیصد و نود و هشت | |
// number prototype | |
console.log((1398).num2persian()); // یک هزار و سیصد و نود و هشت | |
console.log((1.398).num2persian()); // یک ممیز سیصد و نود و هشت هزارم | |
console.log((-13980).num2persian()); // منفی سیزده هزار و نهصد و هشتاد |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// METHOD 1 | |
const numFa = new Intl.NumberFormat('fa-IR', {style : "decimal" }).format(987654321).replace(/٬/g , "") | |
const numAr = new Intl.NumberFormat('ar-AE', {style : "decimal" }).format(987654321).replace(/٬/g , "") | |
console.log(numFa); // ۹۸۷۶۵۴۳۲۱ | |
console.log(numAr); // ٩٨٧٦٥٤٣٢١ | |
// METHOD 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// METHOD 1 | |
const today = Date.now(); | |
const todayFa = { | |
"day" : getDateFormat(today , {"day" : "2-digit"}), | |
"month" : getDateFormat(today , {"month" : "numeric"}), | |
"monthTitle" : getDateFormat(today , {"month" : "long"}), | |
"year" : getDateFormat(today , {"year" : "numeric"}), | |
"dayWeek" : getDateFormat(today , {"weekday" : "long"}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inpNumber = document.getElementById("my-decimal-number"); | |
inpNumber.addEventListener("keyup", handlerSeparateNumbers) | |
// functions | |
function funcReverseString(str) { | |
return str.split('').reverse().join(''); | |
} | |
// event handlers | |
function handlerSeparateNumbers(e) { |