From 9186ab95943b7c2467a0f27f30bed9db3c589b9d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 27 Jun 2015 14:57:44 +0200 Subject: LinkDB::filterDay(): check input date format Signed-off-by: VirtualTam --- application/Utils.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'application/Utils.php') diff --git a/application/Utils.php b/application/Utils.php index 82220bfc..a1e97b35 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -69,4 +69,19 @@ function sanitizeLink(&$link) $link['description'] = escape($link['description']); $link['tags'] = escape($link['tags']); } + +/** + * Checks if a string represents a valid date + * + * @param string a string-formatted date + * @param format the expected DateTime format of the string + * @return whether the string is a valid date + * @see http://php.net/manual/en/class.datetime.php + * @see http://php.net/manual/en/datetime.createfromformat.php + */ +function checkDateFormat($format, $string) +{ + $date = DateTime::createFromFormat($format, $string); + return $date && $date->format($string) == $string; +} ?> -- cgit v1.2.3