Jump to content

Search the Community

Showing results for tags 'php calendar integer month'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I wrote the following code to create a set of 12 php calendars to display specific entries from a database. I have found many posts about converting a date into an integer but can find nothing to convert an integer into a date or more specifically in this case a month. The interesting thing about all of this is that it accepts and integer as a string in a concatinated set of values initially but won't accept the $month after the change at the end of the code when it returns to continue the loop. Can anyone tell me where I'm going wrong here? <?php $month = date("m"); // Initate $month to current month $twelveCount = '1'; // Set count to 1 for loop while($twelveCount != '13') { // Create loop condition to break at 13 producing 12 calendars $monthName = date("F", strtotime($month)); // Grab name of month from $month variable $year = date("Y"); // Initiate $year from current year $firstDate = $month . '/01/' . $year; // Calculate first day of the month, NOTE: It accepts the string integer here; $firstDay = date("D", strtotime($firstDate)); // Grab day of the first date $firstDay = strtoupper($firstDay); // Capitalise first day string $lastDay = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Grab last day of the month $i = '1'; // Set integer to 1 for begining of auto incremental date display $lastDayPlusOne = $lastDay + 1; // Set limit for loop break when days are complete if ($firstDay == 'SUN') {$skipDays = '0';} // Skip spaces on calendar to equal actual first day if ($firstDay == 'MON') {$skipDays = '1';} if ($firstDay == 'TUE') {$skipDays = '2';} if ($firstDay == 'WED') {$skipDays = '3';} if ($firstDay == 'THU') {$skipDays = '4';} if ($firstDay == 'FRI') {$skipDays = '5';} if ($firstDay == 'SAT') {$skipDays = '6';} $count = '0'; // Iniate $count for loop break when first day is in the correct position $calendarDisplay .= '<div style="float:left; width:182px; margin:0px 0px 7px 7px;"> <div style="float:left; width:161px; text-align:left; margin-bottom:5px;">' . $monthName . ' ' . $year . '</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SUN</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">MON</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">TUE</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">WED</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">THU</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">FRI</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SAT</div> <div style="float:left; width:182px;">'; // Create day names for header while($count != $skipDays) { // Output spaces to match day of the week before dates begin $calendarDisplay .= '<div style="float:left; width:23px; padding:4px 0; margin:0px 3px 3px 0px;"></div>'; $count++; } while($i != $lastDayPlusOne) { // Output dates inline with days in header $calendarDisplay .= '<div style="float:left; padding:4px 0; width:23px; margin:0px 3px 3px 0px; background-color:#0C0; font-size:10px; text-align:center;">' . $i . '</div>'; $i++; } $calendarDisplay .= '</div></div>'; // End calendar display // This is where it all goes wrong... if ($month == date("m", strtotime("1/10/10"))) {$month = date("m", strtotime("2/10/10")); echo $month;} if ($month == '02') {$month = date("m", strtotime("3/10/10")); echo $month;} if ($month == '03') {$month = '04'; echo $month;} /* if ($month == '04') {$month = date("m", strtotime("5/10/10")); echo $month;} if ($month == '05') {$month = date("m", strtotime("6/10/10")); echo $month;} if ($month == '06') {$month = date("m", strtotime("7/10/10")); echo $month;} if ($month == '07') {$month = date("m", strtotime("8/10/10")); echo $month;} if ($month == '08') {$month = date("m", strtotime("9/10/10")); echo $month;} if ($month == '09') {$month = date("m", strtotime("10/10/10")); echo $month;} if ($month == '10') {$month = date("m", strtotime("11/10/10")); echo $month;} if ($month == '11') {$month = date("m", strtotime("12/10/10")); echo $month;} if ($month == '12') {$month = date("m", strtotime("01/10/10")); echo $month;} */ $twelveCount++; // Increment $twelveCount by 1 } // End while($twelveCount != '13') { echo $calendarDisplay; // Echo result out to page ?>
×
×
  • 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.