Jump to content

date calculation


sofia403

Recommended Posts

Hi i was wondering if its possible to not display negative values or maybe there some other way to do this when date is calculated. in this case i have days, and the result brings "- 123" or "- 56" i just want it to show anything that's not negative. thanks.

 

$start_ts = strtotime($row['Applied']); // when process started
$end_ts = strtotime($row['Approval']); // when process finished
$Approval = floor(($end_ts - $start_ts) / (60*60*24)); // days difference from start to finish

Link to comment
https://forums.phpfreaks.com/topic/238227-date-calculation/
Share on other sites

$start_ts = strtotime($row['Applied']); // when process started
$end_ts = strtotime($row['Approval']); // when process finished
$date_diff = ($end_ts - $start_ts);
$Approval = ($date_diff>0) ? floor($date_diff/ (60*60*24)) : ''; // days difference from start to finish

Link to comment
https://forums.phpfreaks.com/topic/238227-date-calculation/#findComment-1224202
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.