ScoobyDont Posted March 4, 2017 Share Posted March 4, 2017 Hi Is it possible to go above 12mths using %m, so for example 5 years = 60mths I am using this code to change the colour of panels which works ok until I make the due date 1yr 2 mths away it makes the panel go red, I need it to stay green and echo 14 mths <?php $expire = $dates->datedue; $date = new DateTime($expire); $now = new DateTime(); ?> <div class="col-md-3"> <div class="panel <?php if ($now->diff($date)->format("%m") < 3) { echo 'panel-red'; } else if ($now->diff($date)->format("%m") < 6) { echo 'panel-orange';} else { echo 'panel-green'; } ?>"> <div class="dark-overlay">Due Date</div> <div class="panel-body"> <h4 class="duedate"><?php echo $now->diff($date)->format("%m Months");?></h4> </div> </div> <?php if ($now->diff($date)->format("%m") < 3) { echo '<div class="text-center"><button class="btn btn-success"> Book Now</button></div>'; } ?> </div> So the question is Is it possible to have more than 12mths? Quote Link to comment Share on other sites More sharing options...
ScoobyDont Posted March 5, 2017 Author Share Posted March 5, 2017 Its ok I have solved it Quote Link to comment Share on other sites More sharing options...
requinix Posted March 5, 2017 Share Posted March 5, 2017 %y * 12 + %m Great that you solved it, but posting the solution you came up with would be even better. Quote Link to comment Share on other sites More sharing options...
ScoobyDont Posted March 5, 2017 Author Share Posted March 5, 2017 Ooops my bad, sorry But thanks for adding the solution for me. Quote Link to comment 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.