I am trying to calculate time with datejs and timejs but I am not getting it.
how can i do this?
var startTime ="20:55",
endTime ="22:33",
st = (startTime.toString("HH:mm")),
et=(endTime.toString("HH:mm"));
console.log(new TimeSpan(et-st));
logged: NaN:NaN:NaN { milliseconds=NaN, days=NaN, hours=NaN
startTimeandendTimeare strings, and you want them to be milliseconds.EDIT: I initially had
.getTime()on the end of theDate.parse()s, but as geoffrey.mcgill pointed out, it wasn’t necessary.