Jump to content

How to pass current month in php


spratap2312

Recommended Posts

HI ,

I have below php code in which the month is hardcoded , how can i pass current month to it.

 <?php
   echo "<li style=\"display: list-item;\" ><a href=\"#\"></a>
    <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=02&SITE=WWDC\">WWDC</a></li>
    <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=02&SITE=NOIDA\">Noida</a></li>
    <li style=\"display: list-item;\" ><a href=\"#\"></a></li>";
 ?>
 
Link to comment
Share on other sites

HI ,

I passed the parameter as below

 

  
<?php
   echo "<li style=\"display: list-item;\" ><a href=\"#\"></a>
    <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=date(m)&SITE=WWDC\">WWDC</a></li>
    <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=date(m)&SITE=NOIDA\">Noida</a></li>
    <li style=\"display: list-item;\" ><a href=\"#\"></a></li>";
 ?>
 
but it is giving error when the target php is getting called
what should be the syntax of it.
Link to comment
Share on other sites

If what you posted really is what you're working with, meaning that the echo is the only bit of code you have between those <?php ?> tags, then wouldn't you agree that

<?php

$month = date("m");

?>
<li style="display: list-item;" ><a href="#"></a>
<li style="display: list-item;" ><a href="http://mis.sgp.st.com/OVO_Alerts.php?MONTH=<?=$month?>&SITE=WWDC">WWDC</a></li>
<li style="display: list-item;" ><a href="http://mis.sgp.st.com/OVO_Alerts.php?MONTH=<?=$month?>&SITE=NOIDA">Noida</a></li>
<li style="display: list-item;" ><a href="#"></a></li>
is much easier to look at?

 

You're also missing a on that first link, though I don't believe it's technically required.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.