dbair Posted July 31, 2007 Share Posted July 31, 2007 Any idea why dates go from august to october missing september? where current month = July (07) $curYM = date("Y-m"); // 2007-07 $nextMnth = date("Y-m", strtotime("+1 months")); // 2007-08 Both of the two below give back 2007-10 $twoMnth = date("Y-m", mktime(0,0,0,date('m')+2)); // 2007-10 - should be 2007-09 $twoMnth = date("Y-m", strtotime("+2 months")); // 2007-10 - should be 2007-09 Thanks in advance! David Link to comment https://forums.phpfreaks.com/topic/62656-solved-missing-september/ Share on other sites More sharing options...
soycharliente Posted July 31, 2007 Share Posted July 31, 2007 date() returns a string. You're adding a string to a number when you say date('m')+2. Could that be it? Link to comment https://forums.phpfreaks.com/topic/62656-solved-missing-september/#findComment-311837 Share on other sites More sharing options...
dbair Posted July 31, 2007 Author Share Posted July 31, 2007 No because date('m') returns 7 and +2 should be 9 but is 10. Link to comment https://forums.phpfreaks.com/topic/62656-solved-missing-september/#findComment-311844 Share on other sites More sharing options...
soycharliente Posted July 31, 2007 Share Posted July 31, 2007 But my point is that date() returns a string. And you are trying to add a number to a string. It MIGHT be a problem with the data types. That's all I was suggesting. Link to comment https://forums.phpfreaks.com/topic/62656-solved-missing-september/#findComment-311849 Share on other sites More sharing options...
dbair Posted July 31, 2007 Author Share Posted July 31, 2007 figuted it out. I used this to get September to work corectly where date("Y-m") = 2007-07: $twoMnth = date("Y-m", mktime(0, 0, 0, date("m")+3, 0, date("Y"))); Link to comment https://forums.phpfreaks.com/topic/62656-solved-missing-september/#findComment-311932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.