0

How do I display date ranges for Value1 and Value2 in the following format where value2 is display as the difference between Value1 and Value2 expressed in days. I'd like to rewrite the results of a view field using PHP code.

Value1=1-Jan-2013

Value2=6-Jan-2013

i.e. result expected:

1-Jan-2013 +5d
1
<?php
$datetime1 = date('d-M-Y', strtotime(value1));
$datetime2 = date('d-M-Y', strtotime(Value2));
$interval = date_diff($datetime1, $datetime2);
$result = $datetime1 . ' ' . $interval;

result will be 1-Jan-2013 +5d

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.