1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.

Days between 2 dates in PHP

Aug 11, 2013
Days between 2 dates in PHP
  • This gives the difference in days between a date element and today, Alternatively you could swap 'today' with another date or field

    PHP:
    $nowdate = strtotime("{table___element}");
    $thendate = strtotime("today");
    $datediff = ($thendate - $nowdate);
    $diff = round($datediff / 86400);
    return $diff;
    It was used in a schedule task email plugin that required multiple conditions to be met, as follows

    PHP:
    $cond1 = ('{table___element}' == 'X');
    $nowdate = strtotime("{table___element}");
    $thendate = strtotime("today");
    $datediff = ($thendate - $nowdate);
    $diff = round($datediff / 86400);
    $cond2 = ($diff == X);
    return $cond1 <> $cond2;
    Send a reminder email only to the rows(users) that didn't update a record for more than 16 days.

    PHP:
    $date1 = strtotime("{table___update_raw}");
    $date2 = strtotime("{table___createdate_raw}");
    $date2 = strtotime("+16 day", $date2);
    return $date1 > $date2;
nelly likes this.