You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Objective:


วัตถุประสงค์:


To calculate the duration between 2 given dates

เพื่อคำนวณระยะเวลาระหว่าง 2 วันที่กำหนด

Screenshot:

ภาพหน้าจอ:

Code:

รหัส:

$('input[name="fromDatepicker"], input[name="toDatepicker"]').change( function(){
      d1 = $('input[name="fromDatepicker"]').datepicker('getDate');
      d2 = $('input[name="toDatepicker"]').datepicker('getDate');
      diff = 0;
      if (d1 && d2) {
            diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day
      }
      $('input[name=days]').val(diff);
});

Sample App Download

ดาวน์โหลดแอปตัวอย่าง


APP_calculateDateDiff-1-20160404092232.zip

  • No labels