Location: PHPKode > scripts > K-Pregs > k-pregs/examples/date.php
<?php

require("../kpregs.php");

/*
Check for valid date
*/

// Basic exact date validation
if (kpreg_is_valid_date("24.12.2006",".","d.m.y")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic exact date validation
if (kpreg_is_valid_date("24/12/2006","/","d/m/y")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic exact date validation
if (kpreg_is_valid_date("12-24-2006","-","m-d-y")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic exact date validation
if (kpreg_is_valid_date("2006-12-24","-","y-m-d")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic exact date validation
if (kpreg_is_valid_date("1988-12-24","-","y-m-d",1989,2006)) // Not valid because year is not >= 1989
 echo("Valid!");
else
 echo("Invalid!");

// Basic inexact date validation
if (kpreg_is_valid_date("24.12.2006")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic inexact date validation
if (kpreg_is_valid_date("24/2006/12")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic inexact date validation
if (kpreg_is_valid_date("01=01=2006")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

// Basic inexact date validation
if (kpreg_is_valid_date("1.1.2006")) // Valid
 echo("Valid!");
else
 echo("Invalid!");

?>
Return current item: K-Pregs