I am working with dates can anyone know how to get difference of two event.timestamp(). In my form I am having Start button and Stop button. I want time elapse between two event.getTimeStamp() in format of HH:MM. How can I get the hours and minutes.
This works for me. I have it as a function in my database so any change to the two fields automatically updates the elapsed field.
Uses Dateutils plugin
function TimeTaken()
{
// Create an “empty” duration and set its fields later
var vDuration = plugins.DateUtils.Duration();
vDuration.days = 22;
vDuration.hours = 9;
vDuration.minutes = 12;
vDuration.seconds = 8;
var vlinstart = plugins.DateUtils.DateTime(linstart);
var vlinstop = plugins.DateUtils.DateTime(linstop);
vDuration = plugins.DateUtils.Duration(vlinstart,vlinstop);
return vDuration.hours + vDuration.minutes / 60
}
Regards
Mark
I actually prefer Roberts implementation because it doesn’t return decimals and it doesn’t rely on the optional dateUtils plugin (newcomers might not know it is not included with Servoy, feature request?).