Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View senior-x-79's full-sized avatar

senior-x-79

View GitHub Profile
@senior-x-79
senior-x-79 / convert-date-to-persian-in-javascript.js
Created January 20, 2022 21:46
تبدیل تاریخ از شمسی به میلادی یا میلادی به شمسی با 2 روش در جاوا اسکریپت
// 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"}),
@senior-x-79
senior-x-79 / english number to persian.js
Created January 20, 2022 20:59
تبدیل عدد از انگلیسی به فارسی / عربی در جاوا اسکریپت - how to convert english number to Persian/Arabic Number
// 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
@senior-x-79
senior-x-79 / number-to-persian-letters.js
Created August 9, 2021 11:14
how to convert number to persian number with js
// # 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()); // منفی سیزده هزار و نهصد و هشتاد
@senior-x-79
senior-x-79 / separate numbers in javascript.js
Last active February 20, 2024 13:10
how to separate numbers in javascript
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) {