Results 1 to 8 of 8

Thread: How to count days

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    70

    Exclamation How to count days

    How to get number of days between two dates.for example (starting date and ending date).please help me.thank you

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    pseudo code:
    Code:
    var delta = Date.parse(endtime) - Date.parse(starttime);
    var days = parseInt(delta / 86400).toString();
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  4. #4
    Sencha User
    Join Date
    Jul 2009
    Posts
    70

    Default

    ya i included this but its giving value as NAN

  5. #5
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    you included what? Code please.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  6. #6
    Sencha User
    Join Date
    Jul 2009
    Posts
    70

    Default

    var delta = Date.parse(endtime) - Date.parse(starttime);
    var days = parseInt(delta / 86400).toString();

    In my application starttime is Reseravation_Start (its value:2009-06-27)
    and end time is Reseravation_End_Start (its value:2009-07-05)
    so i changed it as

    var delta = Date.parse(Reseravation_End_Start) - Date.parse(Reseravation_Start);
    var days = parseInt(delta / 86400).toString();

    This coding only i included

  7. #7
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    these strings are no valid time strings.

    better to use Date class from ExtJS as evant already posted, then you can
    Code:
    var starttime = Date.parseDate('2009-06-27', 'Y-m-d');	
    var endtime = Date.parseDate('2009-07-05', 'Y-m-d');
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  8. #8
    Sencha User
    Join Date
    Jul 2009
    Posts
    70

    Default

    thanks alot i got the output

Posting Permissions

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