Link to home
Start Free TrialLog in
Avatar of aswathi rajasekar
aswathi rajasekar

asked on

php code

while using php code for each month and date .....why cant we use "if condition" or any other looping condition
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

I don't understand your question. It might help to see an example of what you have and what you want. In the meantime, here's an example of looping through the next 12 months:

<?php
$date = new DateTime();
for($i = 0; $i < 12; $i++)
{
  echo $date->format('Y-m') . "\n";
  $date->modify('+1 month');
}
Avatar of aswathi rajasekar
aswathi rajasekar

ASKER

yea this is what is asked..thnq
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.