Change Datetime Fomat

I am Using Following script to change Date Format
{{ frappe.utils.formatdate(doc.get_formatted(‘posting_date’), “dd-MM-yyyy”) }}

but I am getting Error doc.get_formatted is not a function.

again I am getting error frappe.utils.get_datetime is not a function

Hi @hari.kishor,

have you tried

{{ frappe.utils.get_datetime(doc.posting_date).strftime('%Y-%m-%d') }} 

or you can also try

{{ doc.get_formatted('posting_date', 'en-us') }}

Hope this helps :wink:

Hi @lasalesi ,

again I am getting error doc is not defined.

Thank You

Please share you code. Note, the second snippet does not have the doc.posting_date, but uses a different semantic… You are in a print format, right?

Thank You @lasalesi
I found the solution through the script.

var today = new Date(d.communication_date);
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var today = dd+'-'+mm+'-'+yyyy;
1 Like