Skip to content

Instantly share code, notes, and snippets.

@Goudarz
Created September 13, 2023 20:29
Show Gist options
  • Save Goudarz/9487cc9ff8c85d9c2226420b28fc4762 to your computer and use it in GitHub Desktop.
Save Goudarz/9487cc9ff8c85d9c2226420b28fc4762 to your computer and use it in GitHub Desktop.
Convert the Gregorian date to Jalali(Shamsi) in Google Sheets
/*
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