Static/PhpInclude/FareOfficeLib/General/Date.php File Reference

Includes date manipulating functions. More...

Go to the source code of this file.

Functions

 isValidDate ($date_)
 Returns true if the input variable is a valid date or datetime.
 isValidTime ($time_)
 Returns true if the input variable is a valid time.


Detailed Description

Includes date manipulating functions.

Author:
Daniel Lindh <[email protected]>

Definition in file Date.php.


Function Documentation

isValidDate ( date_  ) 

Returns true if the input variable is a valid date or datetime.

 isValidDate('2006-01-01');
 isValidDate("2006-01-01 21:02:02")'));
 isValidDate("now")'));
 isValidDate("12jan2009")'));

Parameters:
$date_ - dateTime - The date to validate.
Returns:
- boolean -

Definition at line 25 of file Date.php.

Referenced by UrlRequst::getDateTime().

00026 {
00027   $time = strtotime($date_);
00028   if ($time === false)
00029   {
00030     return false;
00031   }
00032 
00033   return true;
00034 }

isValidTime ( time_  ) 

Returns true if the input variable is a valid time.

  • Need to have all parts of the time hh:mm:ss

 isValidTime('21:02:00');

Parameters:
$time_ - string -
Returns:
- boolean-

Definition at line 47 of file Date.php.

00048 {
00049   $matches = NULL;
00050   preg_match('/^([\d]{1,2})[:]{1}([\d]{2})[:]{1}([\d]{2})$/', $time_, $matches);
00051 
00052   if
00053   (
00054     empty($matches) ||
00055     $matches[1] < 0 ||
00056     $matches[1] >= 24 ||
00057     $matches[2] < 0 ||
00058     $matches[2] >= 60 ||
00059     $matches[3] < 0 ||
00060     $matches[3] >= 60
00061   )
00062   {
00063     return false;
00064   }
00065   else
00066   {
00067     return true;
00068   }
00069 }


Generated on Wed May 6 23:28:24 2009 for fareofficelib by  doxygen 1.5.8