Drupal views print date 'time ago' as a PHP conditional field I am trying to make a custom PHP field that returns the value of 'user last access' field as an integer of minutes 'time ago'.

I have created a normal views field for 'user last access' which returns almost exactly what I want from the normal field value:

x mins - this being x mins time ago, created by using 1 as the time units to display.

I just don't know how to return this value through a new PHP field that just references and displays the integer value for this field without ' mins' text ?

I want to then take this raw value and use a conditional statement of:

If user last access is less than 3 minutes print 'Online'
else
Print 'Offline'
In User Last access field UI, under the Date Format, select 'Custom' and then enter custom date format. For minutes you can enter 'i' which will show the number.

Refer http://php.net/manual/en/function.date.php for date formats.

Thanks