ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Change Datetime Fomat


#1

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.


#3

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


#4

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:


#5

Hi @lasalesi ,

again I am getting error doc is not defined.

Thank You


#6

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?


#7

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();
if(dd<10){
    dd='0'+dd;
} 
if(mm<10){
    mm='0'+mm;
} 
var today = dd+'-'+mm+'-'+yyyy;

#8