Results 1 to 3 of 3

Thread: Jason's Date Input Calendar query

  1. #1
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Jason's Date Input Calendar query

    Hi there,

    I have used Jason's Date Input Calendar, and need a extra functrion for my form to work.
    I have two calendar's, an arrival date and a departure date.
    I need to count the number of days between the arrival date and the departure date.
    Calendar's are setup as follows:
    HTML Code:
    <td colspan="3">Arrival date:
    <script type="text/javascript">// <![CDATA[
    DateInput('orderdate1', true, 'DD-MON-YYYY')
    // ]]></script>
    </td>
    HTML Code:
    <td colspan="3">Departure date:
    <script type="text/javascript">// <![CDATA[
    DateInput('orderdate2', true, 'DD-MON-YYYY')
    // ]]></script>
    </td>
    Could you please advice how I can calculate the amount of days between the two dates then place the number of days into a textbox.

    Thank you in advance :-)

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Here's a function to get the difference between two dates:
    Code:
    function calcDate(date1, date2) {
      var one_day=1000*60*60*24;
    
      var date1_ms = date1.getTime();
      var date2_ms = date2.getTime();
    
      var difference_ms = date2_ms - date1_ms;
     
      return Math.round(difference_ms/one_day); 
    }
    So in order to get the date difference, it would be:
    Code:
    document.getElementById('yourTextBox').value = calcDate(this.form.outerdate1.value, this.form.outerdate2.value);
    The only issue, may be format of the date, so you may need to change that.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  3. #3
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you Bernie, will give it try and let you know if resolved. :-)

Similar Threads

  1. Jason's Date Input Calendar - Need Help to Display Empty Date Fields?
    By Dorgs in forum Dynamic Drive scripts help
    Replies: 9
    Last Post: 06-07-2013, 02:08 PM
  2. passing & recieving a date with mysql using Jason's Date Input Calendar
    By kkslider in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-19-2012, 04:30 PM
  3. Jason's Date Input Calendar - Calendar reappearing in IE8
    By NGJ in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-30-2011, 01:30 PM
  4. Jason's Date Input Calendar onClick to change the showing date
    By williamstam in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-13-2008, 12:48 PM
  5. Replies: 1
    Last Post: 11-04-2005, 05:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •