code snippet: isDateInterval() mm/dd/yyyy

Include file:

/web/includes/generalFormFuncs.php

Usage Example:

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

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

mm/dd/yyyy

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
Advertisements

About samehramzylabib

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

Comment

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s