Is there any way to use Date format in hindi in Print format

In Date format is their any functionality for using month in hindi.
e.g. frappe.utils.formatdate(h.due_date, “dd-MMM-yyyy”) this gives 19-Mar-2023 instead of this ,
I want like this 19-मार्च-2023.
Is it possible.
Thank you

Hi @Sakshi_Choudhary,

Please apply it.

frappe.ui.form.on('Your Doctype', {
    refresh: function(frm) {
        // Get the value of the due_date field
        var dueDate = frm.doc.due_date;

        // Convert the date to the desired format
        var formattedDate = frappe.datetime.str_to_user(dueDate);
        var dateParts = formattedDate.split('-');
        var hindiMonth = getHindiMonth(dateParts[1]);

        // Replace the English month with the Hindi month
        dateParts[1] = hindiMonth;

        // Format the date with the Hindi month
        var hindiFormattedDate = dateParts.join('-');

        // Set the formatted date in a custom field
        frm.set_value('custom_date_field', hindiFormattedDate);

// Function to get the Hindi month name
function getHindiMonth(month) {
    var hindiMonths = {
        '01': 'जनवरी',
        '02': 'फरवरी',
        '03': 'मार्च',
        '04': 'अप्रैल',
        '05': 'मई',
        '06': 'जून',
        '07': 'जुलाई',
        '08': 'अगस्त',
        '09': 'सितंबर',
        '10': 'अक्टूबर',
        '11': 'नवंबर',
        '12': 'दिसंबर'

    return hindiMonths[month];

Please set your doctype and field name according.
I hope this helps.

We applied in Sales Order.

Thank You!


Thank you…

I follow this snippet, this also works for this requirement…
{{frappe.utils.formatdate(doc.loan_date, “dd-MMMM-yyyy”)|replace(‘January’,‘जनवरी’)|replace(‘February’,‘फ़रवरी’)|replace(‘March’,‘मार्च’)|replace(‘April’,‘अप्रैल’)|replace(‘May’,‘मई’)|replace(‘June’,‘जून’)|replace(‘July’,‘जुलाई’)|replace(‘August’,‘अगस्त’)|replace(‘September’,‘सितंबर’)|replace(‘October’,‘अक्टूबर’)|replace(‘November’,‘नवंबर’)|replace(‘December’,‘दिसंबर’) }}
Thank you

1 Like