WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar Update Picture
Erwin Sanjaya
Date : Feb 15th 2001
Grade : 2 of 5 (graded 10 times)
Viewed : 10768
File : fotoku.jpg
Images : No Images for this code example.
Search : More code by Erwin Sanjaya
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
    $now
=date("g-i-s-n-j-Y");
    list(
$hour,$minute,$second,$month,$date,$yearbefore)=explode("-",$now);

   
$zonefile=file("templates/timezone");
   
$timezone=$zonefile[0];
             
   
$now=date("l-d-F-Y-n",mktime(($hour+$timezone),$minute,$second,$month,$date,$yearbefore));
    list(
$day,$date,$month,$yearafter,$monthdigit)=explode("-",$now);

   
$first=date("w-t",mktime((0+$timezone),0,0,$monthdigit,1,$yearbefore));
    list(
$firstday,$sumofdays)=explode("-",$first);
   
$lastday=date("w",mktime((0+$timezone),0,0,$monthdigit,$sumofdays,$yearbefore));

    if(
$firstday){
       
$sunday=1+(7-$firstday);
        if(
$sunday==7) $sunday=0;
    } else {
     
$sunday=1;
    }

   
$sumofdaysbefore=date("t",mktime((0+$timezone),0,0,($monthdigit-1),1,$yearbefore));
    for(
$i=0;$i<$firstday;$i++){
       
$datelist[$i]=$sumofdaysbefore - $firstday + $i + 1;
       
$colorlist[$i]="C0C0C0";
    }

    for(
$i=$firstday,$d=1;$d<=$sumofdays;$i++,$d++){
       
$datelist[$i]=$d;
        if((
$d%7)==$sunday) { $colorlist[$i]="FF0000"; }
        else {
$colorlist[$i]="000000"; }
        if(
$d==$date) $colorlist[$i]="00BB00";
    }

   
$sumofdatenow=sizeof($datelist);
    for(
$i=$sumofdatenow,$s=0;$s<(6-$lastday);$i++,$s++){
       
$datelist[$i]=$s+1;
       
$colorlist[$i]="C0C0C0";
    }

   
$week=file("templates/week.htm");
    for(
$i=0;$i<sizeof($week);$i++){
       
$cldrlist.=$week[$i];
    }

   
$sumofweek=sizeof($datelist)/7;
    for(
$i=0;$i<$sumofweek;$i++){
       
$idx=$i*7;
       
$idx1=$idx+1;
       
$idx2=$idx+2;
       
$idx3=$idx+3;
       
$idx4=$idx+4;
       
$idx5=$idx+5;
       
$idx6=$idx+6;
       
$weeklist=$cldrlist;
       
$weeklist=ereg_replace("1X","$datelist[$idx]",$weeklist);
       
$weeklist=ereg_replace("1COLOR",$colorlist[$idx],$weeklist);
       
$weeklist=ereg_replace("2X","$datelist[$idx1]",$weeklist);
       
$weeklist=ereg_replace("2COLOR",$colorlist[$idx+1],$weeklist);
       
$weeklist=ereg_replace("3X","$datelist[$idx2]",$weeklist);
       
$weeklist=ereg_replace("3COLOR",$colorlist[$idx+2],$weeklist);
       
$weeklist=ereg_replace("4X","$datelist[$idx3]",$weeklist);
       
$weeklist=ereg_replace("4COLOR",$colorlist[$idx+3],$weeklist);
       
$weeklist=ereg_replace("5X","$datelist[$idx4]",$weeklist);
       
$weeklist=ereg_replace("5COLOR",$colorlist[$idx+4],$weeklist);
       
$weeklist=ereg_replace("6X","$datelist[$idx5]",$weeklist);
       
$weeklist=ereg_replace("6COLOR",$colorlist[$idx+5],$weeklist);
       
$weeklist=ereg_replace("7X","$datelist[$idx6]",$weeklist);
       
$weeklist=ereg_replace("7COLOR",$colorlist[$idx+6],$weeklist);

         
$calendar.=$weeklist;
    }

   
$template=file("templates/calendar.htm");

    for(
$i=0;$i<sizeof($template);$i++){
       
$line=$template[$i];
       
$line=ereg_replace("DAY",$day,$line);
       
$line=ereg_replace("DATE",$date,$line);
       
$line=ereg_replace("MONTH",$month,$line);
       
$line=ereg_replace("YEAR",$yearafter,$line);
       
$line=ereg_replace("<!--LIST OF CALENDAR-->",$calendar,$line);
        echo
$line;
    }

?>



these are the template files :
calendar.htm
<p align="center"><font size="2" face="helvetica, arial, verdana"color="#FFFFFF">DAY<br>
</font><b><font size="6" color="#FF0000" face="helvetica, arial,verdana">DATE</font><font size="6"><br>
</font></b><font color="#FFFFFF" face="helvetica, arial, verdana"><fontsize="2">MONTH, YEAR</font></font></p>
<table border="1" width="20%" cellspacing="0" cellpadding="0" bordercolor="#808080"align="center">
  <tr>
    <td width="100%">
      <table border="0" width="100%" bgcolor="#808080" cellspacing="0"cellpadding="0">
        <tr>
          <td width="100%">
            <p align="center"><b><font size="2" face="arial, helvetica, verdana"color="#FF0000"><</font><font size="2" face="arial, helvetica, verdana" color="#FFFFFF"> MONTH</font><font size="2" face="arial, helvetica, verdana" color="#FF0000"> ></font></b></p>
          </td>
        </tr>
      </table>
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="100%" colspan="7" bgcolor="#FFFFFF">
            <p align="center"><b><font size="2" face="arial, helvetica, verdana"color="#FF0000"><</font><font size="2" face="arial, helvetica, verdana" color="#000000"> YEAR</font><font size="2" face="arial, helvetica, verdana" color="#FF0000"> ></font></b></td>
        </tr>
        <tr>
          <td width="15%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#AA0000">S</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">M</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">T</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">W</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">T</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">F</font></b></td>
          <td width="15%" bgcolor="#FFFFFF">
            <p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">S</font></b></td>
        </tr>
<!--LIST OF CALENDAR-->
      </table>
    </td>
  </tr>
</table>


week.htm
       <tr>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#1COLOR" size="1" face="helvetica,arial, verdana">1X</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#2COLOR" size="1" face="helvetica,arial, verdana">2X</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#3COLOR" size="1" face="helvetica,arial, verdana">3X</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#4COLOR" size="1" face="helvetica,arial, verdana">4X</font></b></td>
          <td width="14%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#5COLOR" size="1" face="helvetica,arial, verdana">5X</font></b></td>
          <td width="15%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#6COLOR" size="1" face="helvetica,arial, verdana">6X</font></b></td>
          <td width="15%" bgcolor="#FFFFFF">
            <p align="center"><b><font color="#7COLOR" size="1" face="helvetica,arial, verdana">7X</font></b></td>
        </tr>



timezone
file timezone contains time difference (hour) in one line 
example : my server is in USA and i am in Indonesia
time difference between USA and Indonesia is 7 hours
so file timezone contains one line that is "7" (without quote)



CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time.
Categories : PHP, Calendar, Date Time, HTML and PHP
Simple PHP control CSS Calender
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
Dynamic Calender in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed.
Categories : Date Time, PHP, Complete Programs, Calendar
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used.
Categories : HTML and PHP, PHP, Date Time
If you want to create select buttons featuring current date this example will show you how...
Categories : Date Time, HTML and PHP, PHP
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
php html calender dynamic
Categories : HTML and PHP, PHP, Calendar
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June).
Categories : Calendar, Date Time, PHP