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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.