Created
September 13, 2023 20:29
-
-
Save Goudarz/9487cc9ff8c85d9c2226420b28fc4762 to your computer and use it in GitHub Desktop.
Convert the Gregorian date to Jalali(Shamsi) in Google Sheets
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
/* | |
In Google Sheets, select the Apps Script option from the Extensions menu and replace the introduced function, Save and that's it! | |
You can use it in your cells with these formats: | |
=JALALI( "10/23/2023" ) | |
=JALALI(TODAY()) | |
*/ | |
function JALALI(date) { | |
let jalaliFormat = new Date(date).toLocaleDateString('fa-IR').replace(/([۰-۹])/g, token => String.fromCharCode(token.charCodeAt(0) - 1728)); | |
return jalaliFormat; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment