Custom script for required changes

Hello,

I want to make custom script to count difference between two input times, and difference between two times displays in total time field. So, to achieve this outcome, how can i start scripting and in which file i have to make changes.

I am using local server in development mode.

An example will be more helpful. :slight_smile:

Thanks,
Hardik Gadesha

Please try this.

import frappe.utils

time_diff=frappe.utils.data.time_diff(time1,time2)

Thanks, Sukrut
New Indictranstech pvt.ltd

Thanks @jsukrut for your inputs.

Look my idea is actually like as shown in below figure.

Here i created a custom DocType and put 3 custom DocFields inside it as a 1) Start Time 2) End Time 3) Total Time. For start time and stop time, i put a time picker. Now i want total time difference between those two selected time. So as i am new to coding stuff, how can i calculate time difference and display it to total time field automatically ?

Thanks & Regards,
Hardik Gadesha
Software Engineer @ AIMDek Technologies Pvt Ltd

@Hardik_Gadesha Do you want difference between start time and end time?

Yes @jsukrut. In HH:MM formate. :slight_smile:

@Hardik_Gadesha

import frappe.utils

def validate(self):
time_diff=frappe.utils.data.time_diff(self.endtime,self.starttime,)
self.difference=time_diff

Thanks, Sukrut
New Indictranstech pvt.ltd

Thanks @jsukrut for your efforts.

Let me try first. Where i have to write this code ?

Regards,
Hardik Gadesha

@Hardik_Gadesha
In controller Doctype.py
eg. Meeting.py ( Suppose Meeting is your doctype name)

Okay @jsukrut .

I am running Frappe bench on localhost in development mode not in production mode. So, i have to write JavaScript for time difference calculation, Right ? :question:

Watch frappe developer Training videos .It contain only 10 videos. use below link.

Okay.

Thanks @jsukrut For your kind reply. :slight_smile: