| px | top | add code | search | signup | login | help |
<?php
# Jonathan Chote - 2000-07-06
# onQ Technologies Ltd
# This include file provides an easy way of checking date strings without having
# to convert them in to integers.
# Example file:
# <?php
# include("checkdateinc.inc");
# $yr="2000"; $mnth="12"; $day="15"
# $a = chkdate($yr,$mnth,$day);
# echo $a;
#
# If the date is correct it returns a 1. If it's invalid it returns a 0. Support
s leap years but date format must be: yyyy,mm,dd 2000,7,12 is not valid
# 2000,07,12 is. It will show 2100 as a leap year.
function chkdate($day,$month,$year)
{
if(($month == "03") || ($month == "05") || ($month == "08") || ($month =
= "12") || ($month == "07") || ($month == "10")) {
if($day<32) { return 1; }
else { return 0; }}
if(($month == "01") || ($month == "04") || ($month == "06") || ($month =
= "9") || ($month == "11")) {
if($day<31) { return 1; }
else { return 0; }}
if($month="02") {
$leap=(($year-2000)/4);
$type=gettype($leap);
if($type == "integer") { $daysin="29";} else { $daysin="28"; }
if($day<($daysin+1)) { return 1;} else { return 0; }
}}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.