form : add the conversion format for dates
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2765 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
18
form.php
18
form.php
@@ -301,6 +301,24 @@ class form
|
|||||||
}
|
}
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert Date received in one format to another.
|
||||||
|
* If the provided string is not corresponding to the format, don't change
|
||||||
|
* anything.
|
||||||
|
* Format used http://php.net/manual/en/datetime.createfromformat.php
|
||||||
|
* @param string $inputDate
|
||||||
|
* @param string $inputFormat
|
||||||
|
* @param string $outputFormat
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function convertDate ($inputDate, $inputFormat, $outputFormat)
|
||||||
|
{
|
||||||
|
$date = DateTime::CreateFromFormat ($inputFormat, $inputDate);
|
||||||
|
$errors = $date->getLastErrors();
|
||||||
|
if ($errors["warning_count"] > 0 || $errors["error_count"] > 0)
|
||||||
|
return $inputDate;
|
||||||
|
return $date->format ($outputFormat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the definition of a formfield */
|
/** the definition of a formfield */
|
||||||
|
|||||||
Reference in New Issue
Block a user