Jump to content

Recommended Posts

Hi all

 

I have a form which posts a month & year such as

 

mypage?month=3&year=2009

 

What I need to do is take the month and year which with the above is 3/2009 (march 2009) and then print every day which is in that month, so with the date 3/2009 (march 2009) it would output

 

31

<font>1/3/2009</font>

<font>2/3/2009</font>

<font>3/3/2009</font>

<font>4/3/2009</font>

<font>5/3/2009</font>

<font>6/3/2009</font>

<font>7/3/2009</font>

<font>8/3/2009</font>

<font>9/3/2009</font>

<font>10/3/2009</font>

<font>11/3/2009</font>

<font>12/3/2009</font>

<font>13/3/2009</font>

<font>14/3/2009</font>

<font>15/3/2009</font>

........

 

and so on

 

and then when the url that is posted is

 

mypage?month=4&year=2009

 

it would output

 

<font>1/4/2009</font>

<font>2/4/2009</font>

<font>3/4/2009</font>

....

 

and so on.

 

Is this possible?

 

Any help would be ace

 

Thanks

 

Dave

Link to comment
https://forums.phpfreaks.com/topic/87239-printing-days-in-month/
Share on other sites

You can use the date() function in conjunction with the strtotime() function to get the number of days in a month:

<?php
$days_in_month = date('t',strtotime($_GET['year'] . '-' . $_GET['month'] . '-1'));
for ($i=1;$i<=$days_in_month;$i++)
    echo '<font>' . $i . '/' . $_GET['month'] . '/' . $_GET['year'] . "</font>\n";
?>

 

Ken

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.