1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

jdate Calculations

Discussion in 'Community' started by bespokeappstt, Oct 8, 2021.

Thread Status:
Not open for further replies.
  1. bespokeappstt

    bespokeappstt Hubstaff freelancer

    Level: Community
    I'm calculating the difference in days with a jdate plugin. The following works fine within the month:
    Code (Text):

    $date2 = strtotime('{rad_rentals___due_date_out_raw}');
    $date3 = strtotime('{rad_rentals___due_date_in_raw}');
    return (ceil(($date3 - $date2) / 86400))+1;
     
    But I get an extra day when is not the same month. Once $date2 and $date3 are within the same month, the calculation is good. Once its different months I get an extra day. How can I modify the calculation to get the correct days across months? jdate gives the epoc time? Couldn't get much info on jdate from the wiki.
     
  2. bespokeappstt

    bespokeappstt Hubstaff freelancer

    Level: Community
    What exactly is the jdate plugin? If I knew more about it, I can get what is the month for each jdate and do a calculation from there.
     
  3. troester

    troester Well-Known Member Staff Member

    Level: Community
  4. bespokeappstt

    bespokeappstt Hubstaff freelancer

    Level: Community
    Thank you very much for that link. Mathematically it should be the same but for some strange reason I'm getting the results I want now. I am now using:
    Code (Text):

    $date2 = strtotime('{rad_rentals___due_date_out_raw}');
    $date3 = strtotime('{rad_rentals___due_date_in_raw}');
    $dateDiff = $date3 - $date2;
    return round($dateDiff / 86400)+1;
     
    SOLVED.
     
Thread Status:
Not open for further replies.

Share This Page