How do I calculate the days difference between start and end date of a date range field in Views PHP? I'm trying to get the total number of days in a date range field using Views PHP. Any help will be greatly appreciated.

I tried the code below first in "value code" then in "output code" but it didn't do anything.

$start = strtotime($row-&gt;field_start_and_end_date:value);
$stop = strtotime($row-&gt;field_start_and_end_date:value2); 
$days = $stop-$start;
echo $days;
Within Views PHP, there are 2 fields. The value code field and the output code field. The first is used to calculate the value (for filtering, sorting, etc). The second is used to display the value.

So in the first field you'll have to perform your calculations and return the final value. If your field is numeric, try to only calculate the number here. Prefixes and suffixes can be added in the output field. (So the value for this field could be 3.)

In the output field you again have to return the final value. This can be the same value as calculated in the value field (there is a token for this value). But you can also append pre- and suffixes and return a string. (Here you can for instance append days to the value to have it display 3 days.)