This topic is locked

display time left for a date in list page

5/5/2012 11:06:10 AM
PHPRunner Tips and Tricks
A
acpan author

In the list page, i want to display time left along with the expiry_date field.
Go to List page, add a custom value to the expiry_date as follows:
// if the expiry_date is future date, show how number of Day, Hours, Minutes and seconds left.
if ($value > NOW())

{

$firstTime=strtotime($value);

$lastTime=strtotime(NOW());

// perform subtraction to get the difference (in seconds) between times

$diff=$firstTime-$lastTime;

// convert

$years = floor($diff / (365606024));

$months = floor(($diff - $years
365606024) / (30606024));

$days = floor(($diff - $years 365606024 - $months30606024)/ (606024));

$hours = floor(($diff - $years 365606024 - $months30606024 - $days606024)/ (6060));

$minutes = floor(($diff - $years 365606024 - $months30606024 - $days606024 - $hours6060)/ 60);

$seconds = floor(($diff - $years
365606024 - $months30606024 - $days606024 - $hours6060 - $minutes*60));

//

$time_left = "";

if ($years > 0 ) { $time_left .= $years."Y ";}

if ($days > 0 ) { $time_left .= $days."D ";}

if ($hours > 0 ) { $time_left .= $hours."H ";}

if ($minutes > 0 ) { $time_left .= $minutes."M ";}

if ($seconds > 0 ) { $time_left .= $seconds."S";}

$value .= "<br/><STRONG><FONT COLOR='orange'>Expires in<br/>";

$value .= $time_left;

$value .= "</STRONG></FONT>";

}

else

{
// Show an Expired message below the date in red.

$value .= "<br/><font color='red'>Expired</font>";

}

J
jura 8/8/2012

Hello,
How to modify your code to display mesage : PAYED if i selecet on another field value PAYED
I have another field (InvoiceStatus) where i select from dropdown list is it PAYED or NOT PAYED
THANKS....
TOMO