Last active
March 20, 2021 22:17
-
-
Save farithadnan/6373c301d9def6f20a53c75ddc3dae6b to your computer and use it in GitHub Desktop.
Finding duration between two date. The calculation was made using JavaScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="form-row" > | |
| <div class="form-group col-sm-4"> | |
| <label class="font-weight-bold" for="pstatus">Estimated Start Date</label> | |
| <input type="date" class="form-control form-control-sm" name="estStart" id="estStart" data-group="section-b1"> | |
| </div> | |
| <div class="form-group col-sm-4"> | |
| <label class="font-weight-bold" for="ptype">Estimated End Date</label> | |
| <input type="date" class="form-control form-control-sm" data-group="section-b1" name="estEnd" id="estEnd" placeholder="Please enter the estimated end date"> | |
| </div> | |
| <div class="form-group col-sm-4"> | |
| <label class="font-weight-bold" for="ptype">Estimated duration (Days)</label> | |
| <input type="number" class="form-control form-control-sm" data-group="section-b1" name="estCmp" id="estCmp"> | |
| </div> | |
| </div> | |
| <script> | |
| $(document).ready(function(){ | |
| $("#estEnd").on("change", function () { | |
| var strdate = new Date($("#estStart").val()); | |
| var enddate = new Date($(this).val()); | |
| var timeDiff = Math.abs(enddate.getTime() - strdate.getTime()); | |
| var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); | |
| document.getElementById("estCmp").value = diffDays; | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment