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
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
Mobile Dev World

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 : Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June).
Categories : Calendar, Date Time, PHP Update Picture
Alan Meadows
Date : Jun 01st 2001
Grade : 3 of 5 (graded 3 times)
Viewed : 10434
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alan Meadows
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
function GetTimeStamp($MySqlDate)
{
/*
Take a date in yyyy-mm-dd format and return it to the user in a PHP timestamp
Robin 06/10/1999
*/
        
$date_array = explode("-",$MySqlDate); // split the array
        
$var_year = $date_array[0];
$var_month = $date_array[1];
$var_day = $date_array[2];

$var_timestamp = mktime(0,0,0,$var_month,$var_day,$var_year);
return($var_timestamp); // return it to the user
} // End function GetTimeStamp()

function ordinalDay($ord, $day, $month, $year)
// ordinalDay returns date of the $ord $day of $month.
// For example ordinalDay(3, 'Sun', 5, 2001) returns the
// date of the 3rd Sunday of May (ie. Mother's Day).
//
// Note: $day must be the 3 char abbr. for the day, as
// given by date("D");
//
// By: heymeadows@yahoo.com

{
$firstOfMonth = GetTimeStamp("$year-$month-01");
$lastOfMonth = $firstOfMonth + date("t", $firstOfMonth) * 86400;
$dayOccurs = 0;
        
for ($i = $firstOfMonth; $i < $lastOfMonth ; $i += 86400)
{
if (date("D", $i) == $day)
{
$dayOccurs++;
if ($dayOccurs == $ord)
{ $ordDay = $i; }
}
}
return $ordDay;
} // End function ordinalDay()

function getNextHoliday()
// Looks through a lists of defined holidays and tells you which
// one is coming up next.
//
// By: heymeadows@yahoo.com
{
$year = date("Y");

class holiday
{
var $name;
var $date;
var $catNum;
                        
function holiday($name, $date, $catNum)
// Contructor to define the details of each holiday as it is created.
{
$this->name = $name; // Official name of holiday
$this->date = $date; // UNIX timestamp of date
$this->catNum = $catNum; // category, we used for databases access
}
} // end class holiday
                        
$holidays[] = new holiday("Groundhog Day", GetTimeStamp("$year-2-2"), "20");
$holidays[] = new holiday("Valentine's Day", GetTimeStamp("$year-2-14"), "14");
$holidays[] = new holiday("St. Patrick's Day", GetTimeStamp("$year-3-17"), "15");
$holidays[] = new holiday("Easter", easter_date($year), "16");
$holidays[] = new holiday("Mother's Day", ordinalDay(2, 'Sun', 5, $year), "3");
$holidays[] = new holiday("Father's Day", ordinalDay(3, 'Sun', 6, $year), "4");
$holidays[] = new holiday("Independence Day", GetTimeStamp("$year-7-4"), "17");
$holidays[] = new holiday("Christmas", GetTimeStamp("$year-12-25"), "13");

$numHolidays = count($holidays);
for ($i = 0; $i < $numHolidays; $i++)
{
if ( date("z") > date("z", $holidays[$i]->date) && date("z") <= date("z",
$holidays[$i+1]->date) )
{
$nextHoliday["name"] = $holidays[$i+1]->name;
$nextHoliday["dateStamp"] = $holidays[$i+1]->date;
$nextHoliday["dateText"] = date("F j, Y", $nextHoliday["dateStamp"]);
$nextHoliday["num"] = $holidays[$i+1]->catNum;                
}
}
return $nextHoliday;
} // end function GetNextHoliday


$nextHoliday = getNextHoliday();
echo $nextHoliday["name"]." (".$nextHoliday["dateText"].")";

?>



Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
PHP Calendar Web App
Categories : PHP, Databases, MySQL, Date Time, 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
Calendar, Kalender, date, time, day, month, year
Categories : PHP, Date Time, Calendar
PHP Calendar
Categories : PHP, Calendar, Date Time, Java Script, CSS
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
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
Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time
CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL
Simple PHP control CSS Calendar
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time, PHP, Calendar
Shows the current time as a PNG-image. This script does not use the GD library. You can use it as a benchmark (because it's slow), or as a quick reference for implementing a simple PNG-file generator.
Categories : Graphics, Zlib, Calendar, PHP, Date Time
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