code snippet: isDateInterval() mm/dd/yyyy

Include file:


Usage Example:

if ( strlen($timeInterval) > 0 and !isDateInterval($timeInterval) ) { $isAnomaly = true; }

Date Interval Format (this represents an amount of time – NOT a date):


Code For isDateInterval Function:

function isDateInterval($i_sDate) {
function isDateInterval
boolean isDateInterval(string)
Summary: checks if a date interval is formatted correctly: mm/dd/yyyy (US English)
Author: Sameh Labib
Date: 09/09/2010

  $blnValid = TRUE;
  if ( $i_sDate == "00/00/0000" ) { return $blnValid; }

  if(!ereg ("^[0-9]{2}/[0-9]{2}/[0-9]{4}$", $i_sDate)) {
    $blnValid = FALSE;

  return ($blnValid);
} //end function isDateInterval

About samehramzylabib

See About on
This entry was posted in PHP Code Snippets, PHP Data Value Types, PHP Form Processing, PHP Time Functions and tagged , , . Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s