Posted By

Pjotor on 09/06/11


Tagged

time date tool


Versions (?)

Workhours calculator


 / Published in: JavaScript
 

Usage: worktime([startHours, startMinutes],[endHours, endMinutes]);

  1. var worktime = function(from, to) {
  2. var w = new Date(
  3. new Date(0,0,0,to[0]-1,to[1],0) -
  4. new Date(0,0,0,from[0],from[1],0)
  5. );
  6. return w.getHours() + " hours and " + w.getMinutes() + " minutes";
  7. }

Report this snippet  

You need to login to post a comment.