I need to insert the duration of a task into Pipedrive in the format HH:MM. I have made a small Java script using code in zapier to find the difference between start og end time and thereby find number of hours or minutes that is the duration. But I don't know how to convert this into HH:MM using JavaScript. Any suggestions? Thanks Steve
Asked
Active
Viewed 171 times
0
-
Possible duplicate of [How to format a JavaScript date](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – xavdid Sep 19 '18 at 00:58
-
Hey I assume you are trying to get Calendly working with Pipedrive. I have same issue. Did you figured it out? I would be grateful for reply! – curious Nov 02 '18 at 15:56
1 Answers
0
What is the unit of measurement for the duration that you have?
If it's in minutes, you can use the below code as reference to convert minutes into HH:MM format.
The duration_minutes variable refers to a variable that holds the initial duration that you calculated.
//Calculate hours and minutes from the variable holding the duration
var hours = Math.floor(duration_minutes/60)
var minutes = duration_minutes%60
//Hours less than 10 need a prefix of 0
if (hours < 10){
hours = 0 + hours.toString();
}
else{
hours = hours.toString();
}
//Minutes less than 10 need a prefix of 0
if (minutes < 10){
minutes = 0 + minutes.toString();
}
else{
minutes = minutes.toString();
}
//Join hours and minutes together to make HH:MM format
var fullduration = hours + ":" + minutes;
If duration_minutes is 150, fullduration will become 02:30.

will-yama
- 680
- 5
- 10