|
|
|
|
<?php
/**
* This function gets a year as a parameter and returns an integer,
* which is 29 for leap years and 28 for normal years.
*
* @param int $year
* @return int
*/
function isLeapYear($year)
{
# Check for valid parameters #
if (!is_int($year) || $year < 0)
{
printf('Wrong parameter for $year in function isLeapYear. It must be a positive integer.');
exit();
}
# In the Gregorian calendar there is a leap year every year divisible by four
# except for years which are both divisible by 100 and not divisible by 400.
if ($year % 4 != 0)
{
return 28;
}
else
{
if ($year % 100 != 0)
{
return 29; # Leap year
}
else
{
if ($year % 400 != 0)
{
return 28;
}
else
{
return 29; # Leap year
}
}
}
}
?> | | |
|
| Find the number of days between today and a date in the future or in the past. Categories : PHP, Date Time, Beginner Guides, Data Validation | | | Find the day of the week for any given year/month/day. Categories : PHP, Date Time, Data Validation, Algorithms, 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 | | | Local Time clock and Server time usign PHP and JavaScript Categories : PHP, Java Script, Date Time, Beginner Guides | | | Script loading time Categories : PHP, Beginner Guides, Date Time | | | How to Insert a Date Format Into MySQL from PHP Categories : PHP, Databases, MySQL, Date Time, Beginner Guides | | | Ensure that a specific value lies within a specific range. Categories : PHP, Beginner Guides, Data Validation | | | Validating a URL with preg_match Categories : PHP, Regexps, Beginner Guides, Data Validation | | | Kewl Date Example Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides | | | Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, 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 | | | Form Validation Using PHP to highlight non valid fields Categories : PHP, Form Processing, Data Validation, Beginner Guides | | | Link Submition - Allow your visitors to submit links to the site. Categories : PHP, Arrays, Filesystem, Beginner Guides | | | Function to convert Arabic numbers into Roman Numerals Categories : Algorithms, PHP, Date Time | |
|
|