WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : Find the day of the week for any given year/month/day.
Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides Click here to Update Your Picture
Aris Karidis
Date : Jan 19th 2006
Grade : 2 of 5 (graded 3 times)
Viewed : 16756
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Aris Karidis
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
/**
* Find the day of the week for any given year/month/day.
* $calendarSystem specifies the calendar system
* 0 = Julian calendar
* 1 = Gregorian calendar
*
* @param int $day
* @param int $month
* @param int $year
* @param int $calendarSystem
* @return int
*/
function getDayOfWeek($day, $month, $year, $calendarSystem = 1)
{
   
# Check for valid parameters #
   
if (!is_int($day) || $day < 1 || $day > 31)
    {
       
printf('Wrong parameter for $day. It must be an integer between 1 and 31.');
        exit();
    }
       
    if (!
is_int($month) || $month < 1 || $month > 12)
    {
       
printf('Wrong parameter for $month. It must be an integer between 1 and 12.');
        exit();
    }
       
    if (!
is_int($year) || $year < 0)
    {
       
printf('Wrong parameter for $year. It must be a positive integer.');
        exit();
    }
       
    if (!
checkdate($month, $day, $year))
    {
       
printf('Invalid date.');
        exit();
    }
       
   
# Algorithm #       
   
if ($month < 3)
    {
       
$month = $month + 12;
       
$year = $year - 1;
    }
       
    return (
$day + (2 * $month) + (int) (6 * ($month + 1) / 10) + $year + (int) ($year / 4) - (int) ($year / 100) + (int) ($year / 400) + $calendarSystem) % 7;
}
?>



Find if a year is leap.
Categories : PHP, Date Time, Beginner Guides, Data Validation
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
Count Number Of weeks in Month
Categories : PHP, Date Time, Beginner Guides
Validating a URL with preg_match
Categories : PHP, Regexps, Beginner Guides, Data Validation
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Ensure that a specific value lies within a specific range.
Categories : PHP, Beginner Guides, Data Validation
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
PHP Image Validation Class - test if a specific file is of a certain image type without relying on the said file extension.
Categories : PHP, PHP Classes, Data Validation, Graphics, Beginner Guides
Function to convert Arabic numbers into Roman Numerals
Categories : Algorithms, PHP, Date Time
Form Validation Using PHP to highlight non valid fields
Categories : PHP, Form Processing, Data Validation, Beginner Guides
Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page.
Categories : PHP, Date Time, Beginner Guides, Web Design
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
Script loading time
Categories : PHP, Beginner Guides, Date Time
Local Time clock and Server time usign PHP and JavaScript
Categories : PHP, Java Script, Date Time, Beginner Guides
Reverse a given number
Categories : PHP, Beginner Guides, Algorithms, Math.