PHP Classes

Simple Date Validator: Simple date string validation

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 131 All time: 9,310 This week: 160Up
Version License PHP version Categories
date_validator 1.0.0GNU Free Document...5PHP 5, Time and Date, Validation


This is a simple class for date string validation.

It takes a given date string and a format string as parameters.

The class can reformat the given date using the given format and compares the original date with the formatted date to determine if the date is valid.

This simple class Validates date strings as a valid date, returning true or false on each test case

Picture of johno dread
Name: johno dread is available for providing paid consulting. Contact johno dread .
Classes: 7 packages by
Country: United States United States
Age: ???
All time rank: 1115162 in United States United States
Week rank: 358 Up44 in United States United States Up
Innovation award
Innovation award
Nominee: 1x


$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

  Files folder image Files  
File Role Description
Plain text file datevalidator.php Class main class
Accessible without login Plain text file Tests.php Example Example

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,310
This week:160Up