TapeGun007 Posted June 4, 2010 Share Posted June 4, 2010 Hi, I have a very simple problem that I don't quite understand. In php 4.2, I could use this line: $year = $tempyear -1; works fine. However, in php 5.2 $year becomes equal to nothing. What's the correct way to write this code now? Quote Link to comment https://forums.phpfreaks.com/topic/203917-subtracting-from-a-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2010 Share Posted June 4, 2010 There's nothing wrong with the line of code you posted. It will subtract one from any value in $tempyear and assign that to $year, even if $tempyear does not exist or is a null value or if it is a character string. How do you know you are getting nothing? What value should you be getting? What is your actual code that exhibits the problem? Quote Link to comment https://forums.phpfreaks.com/topic/203917-subtracting-from-a-date/#findComment-1067997 Share on other sites More sharing options...
TapeGun007 Posted June 4, 2010 Author Share Posted June 4, 2010 >.< hmm... weird. I thought I had put an echo statement to show the year and it was coming up. Now it isn't at all. I simply assigned the year the correct value and it works fine. I'm not sure what I was seeing originally or what I did, but I must've made an error somewhere in my troubleshooting. LOL. Originally, I was getting an error on this: $days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year) ; because $year had no value. I thought maybe cal_days_in_month had changed, so I echoed the $year to find it had no value. I then placed that echo command earlier and ... well... I thought it was returning a value... I guess not. Quote Link to comment https://forums.phpfreaks.com/topic/203917-subtracting-from-a-date/#findComment-1067999 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.