date difference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fariba123
    New Member
    • Oct 2006
    • 17

    date difference

    hi

    i have developed an employee details web site. there is an option to view employee's experience.

    in professional experience part i have:
    start date: 01 Mar 2006 and end date:05 Oct 2006

    how can i get the difference between the above dates in the following format:
    days worked:x year (s), y month (s), z day (s)

    please give a quick reply.

    thank you
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Since no one answered this (yet):

    I myself use a PHP class named "Simple Date Time Object" that does all my date/time calculations, also the one you are asking for. You'll find this class at STDO class

    The function you look for is the "diff_MySQL function" (don't be mislead about the word MySQL, it handles you dates fine in the format YYYYMMDDHHMMSS) .

    Sorry I couldn't show you any code for this.

    Ronald :cool:

    Comment

    • ctsasikumar
      New Member
      • Nov 2006
      • 17

      #3
      Hai Use this code it's working perfeclty...... ..i done this same type of application

      $database_date= $acess[3];
      $database_date. "<br>";
      $check_date=exp lode("-",$database_dat e);
      $current_year=d ate("Y");
      $current_month= date("m");
      $current_day=da te("d");
      $end_year=$chec k_date[0];
      $end_month=$che ck_date[1];
      $end_day=$check _date[2];
      $current_date=g regoriantojd($c urrent_month,$c urrent_day,$cur rent_year);
      $final_date=gre goriantojd($end _month,$end_day ,$end_year);
      $possible_acess _date=$final_da te-$current_date;

      Sasi

      Comment

      • fariba123
        New Member
        • Oct 2006
        • 17

        #4
        thanks for the reply. but i failed to understand the usability for date in which format (i.e. [26 Feb 2006] or [Feb26 2006] or [26/02/2006] ).

        it will be great if you explain with a date example.

        thanks

        Originally posted by ctsasikumar
        Hai Use this code it's working perfeclty...... ..i done this same type of application

        $database_date= $acess[3];
        $database_date. "<br>";
        $check_date=exp lode("-",$database_dat e);
        $current_year=d ate("Y");
        $current_month= date("m");
        $current_day=da te("d");
        $end_year=$chec k_date[0];
        $end_month=$che ck_date[1];
        $end_day=$check _date[2];
        $current_date=g regoriantojd($c urrent_month,$c urrent_day,$cur rent_year);
        $final_date=gre goriantojd($end _month,$end_day ,$end_year);
        $possible_acess _date=$final_da te-$current_date;

        Sasi

        Comment

        • ctsasikumar
          New Member
          • Nov 2006
          • 17

          #5
          Hai ...

          GregorianToJD this is php function...

          this function syatax is
          gregoriantojd(m onth,day,year);

          ....

          so i get in the curret date value is first value

          $current_year=d ate("Y");
          $current_month= date("m");
          $current_day=da te("d");

          $current_date=g regoriantojd($c urrent_month,$c urrent_day,$cur rent_year);

          the second i get database value.....

          split the database value in our form using explode function

          $database_date. "<br>";
          $check_date=exp lode("-",$database_dat e);
          $end_year=$chec k_date[0];
          $end_month=$che ck_date[1];
          $end_day=$check _date[2];

          after just subtraction of two value

          $possible_acess _date=$final_da te-$current_date;

          this is given some numeric number....

          u want year wise means

          $year=$possible _acess_date/365;

          do u want month wise means
          $month=$possibl e_acess_date/30;

          that'a ll

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            I fail to see how a Gregorian to Julian date function can help with the problem in this thread.

            (ctsasikumar: before you dump any code in this forum, read the Posting Guidelines at the top of this forum!! And extra attention for the part about enclosing shown code within php, code or html tags!)

            Ronald :cool:

            Comment

            Working...