Calculating time difference between two dates

To calculate the difference, in milliseconds, between two dates, use this JavaScript in a Custom action.

beginTime = new Date();
endTime = new Date();
diff = (endTime - beginTime) / 1000;