Question: I need to calculate the difference between two Date fields in Drupal 7 views.
How do I do this? 
Have installed Views PHP but can not figure out how the Date Fields works.
I have search for this and tried some snippets but now I give up.
The two Date fields in the node are:
Start: 2016-02-06 07:15
Slut: 2016-02-09 16:15
The code snippet I have tried is:

```
$start=$row->field_start;
$slut=$row->field_slut;
$diff=$slut-$start;
print_r($diff);

```

This only result in 0. The values for the two variables are both 4 when I get them in the views PHP field?
Have tried both the Date and Date (Unix timestamp) with the same result.
/Chrotto

Answer: 
You can try something like this:

```
// make sure the values you are getting here are correct
$start_value = $row->field_start;
$end_value = $row->field_slut;

$start_date = new DateObject($start_value);
$end_date = new DateObject($end_value);
$duration = $start_date->diff($end_date);

```
Actually it was worked hours I want to get and after some more digging I found a better way to do this:

```
 $start = strtotime($row->field_start);
 $stop = strtotime($row->field_stop); 
 $time_elapsed=$stop-$start;
 $minutes=$time_elapsed/60;
 $hours=$minutes/60;
 echo $hours;

```