Posted By

krisdb on 07/10/08


Tagged

javascript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

joomla


time differences


 / Published in: JavaScript
 

  1. function timeDifference(laterdate,earlierdate) {
  2. var difference = laterdate.getTime() - earlierdate.getTime();
  3.  
  4. var daysDifference = Math.floor(difference/1000/60/60/24);
  5. difference -= daysDifference*1000*60*60*24
  6.  
  7. var hoursDifference = Math.floor(difference/1000/60/60);
  8. difference -= hoursDifference*1000*60*60
  9.  
  10. var minutesDifference = Math.floor(difference/1000/60);
  11. difference -= minutesDifference*1000*60
  12.  
  13. var secondsDifference = Math.floor(difference/1000);
  14. }

Report this snippet  

You need to login to post a comment.