Set first day to monday.

Discussion in 'PHP' started by munn, Jul 25, 2009.

  1. #1
    This calendar script I found floating around the internet had its first day of the week set to be sunday. I wanted to change it.

    First I renamed the first column to monday instead of sunday. Line 142
    
    [COLOR="Red"]<td><div align="center">Sunday</div></td>[/COLOR]
              <td><div align="center">Monday</div></td>
              <td><div align="center">Tuesday</div></td>
              <td><div align="center">Wednesday</div></td>
              <td><div align="center">Thursday</div></td>
              <td><div align="center">Friday</div></td>
              <td><div align="center">Saturday</div></td>
    
    Code (markup):
    The second difficulty was to get the numbers straight. In this case I had to move em 1 slot. Since this part of the code is unclear to me, I have no idea what I did. Yet it worked. Line 152
    
    for ($i = [COLOR="Red"]1[/COLOR]; $i <= $first_day_of_month-1; $i++) {
    
    Code (markup):
    Changed it to
    
    for ($i = [COLOR="Red"]2[/COLOR]; $i <= $first_day_of_month-1; $i++) {
    
    Code (markup):
    Now a day later, while checking the whole script in action I found out that some months start on the wrong day. For example 2009 feb. starts on monday instead of sunday.

    I REALLY need this to work but just cant figure it out. So, if theres anyone out there, who has the time to test it or look into this issue, please help me. This script is supposed to be a part of a bigger project.

    You can find the script in the attachment.
    My biggest thanks for your time,
    Rist.
     

    Attached Files:

    munn, Jul 25, 2009 IP
  2. munn

    munn Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Figured it out.

    Changed line 52 from
    
    $first_day_of_month = date ("w", mktime(0,0,0,$_GET['month']-[COLOR="Red"]1,1,[/COLOR]$_GET['year']));
    
    Code (markup):
    to

    
    $first_day_of_month = date ("w", mktime(0,0,0,$_GET['month']-[COLOR="Red"]1,[/COLOR]$_GET['year']));
    
    Code (markup):
    Would have done faster if someone looked into it :/
     
    munn, Jul 26, 2009 IP