conan318 Posted January 28, 2012 Share Posted January 28, 2012 returns -30. how can i remove the minus so it just returns 30 $days = (strtotime(date("Y-m-d")) - strtotime($info['expiredate'])) / (60 * 60 * 24) echo $days Quote Link to comment https://forums.phpfreaks.com/topic/255930-day-count/ Share on other sites More sharing options...
litebearer Posted January 28, 2012 Share Posted January 28, 2012 perhaps invert the two strtotimes? Quote Link to comment https://forums.phpfreaks.com/topic/255930-day-count/#findComment-1311941 Share on other sites More sharing options...
lonewolf217 Posted January 28, 2012 Share Posted January 28, 2012 so long as you are sure the calculation is always in the right order, you can just use the abs() function to always display the positive number. of course if the calculation may be backwards then litebearer's answer is correct Quote Link to comment https://forums.phpfreaks.com/topic/255930-day-count/#findComment-1311942 Share on other sites More sharing options...
conan318 Posted January 28, 2012 Author Share Posted January 28, 2012 abs function seems to be doing the trick will see how it goes over the next few days. cheers Quote Link to comment https://forums.phpfreaks.com/topic/255930-day-count/#findComment-1312070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.