PHP Classes

File: Tests.php

Recommend this page to a friend!
  Classes of johno dread   Simple Date Validator   Tests.php   Download  
File: Tests.php
Role: Example script
Content type: text/plain
Description: Example
Class: Simple Date Validator
Simple date string validation
Author: By
Last change:
Date: 8 years ago
Size: 1,135 bytes
 

Contents

Class file image Download
$validdate = new datevalidator();

$validdate->pre( $validdate->validate('2012-02-28 12:12:12')); # true


$validdate->pre($validdate->validate('2012-02-30 12:12:12')); # false
$validdate->pre($validdate->validate('2012-02-28', 'Y-m-d')); # true
$validdate->pre($validdate->validate('28/02/2012', 'd/m/Y')); # true
$validdate->pre($validdate->validate('30/02/2012', 'd/m/Y')); # false
$validdate->pre($validdate->validate('14:50', 'H:i')); # true
$validdate->pre($validdate->validate('14:77', 'H:i')); # false
$validdate->pre($validdate->validate(14, 'H')); # true
$validdate->pre($validdate->validate('14', 'H')); # true

$validdate->pre($validdate->validate('2012-02-28T12:12:12+02:00', 'Y-m-d\TH:i:sP')); # true
//# or
$validdate->pre($validdate->validate('2012-02-28T12:12:12+02:00', DateTime::ATOM)); # true

$validdate->pre($validdate->validate('Tue, 28 Feb 2012 12:12:12 +0200', 'D, d M Y H:i:s O')); # true
//# or
$validdate->pre($validdate->validate('Tue, 28 Feb 2012 12:12:12 +0200', DateTime::RSS)); # true
$validdate->pre($validdate->validate('Tue, 27 Feb 2012 12:12:12 +0200', DateTime::RSS)); # false