From 47a56aa5a44e65242f9419289cc7a8bfe5d8d0c1 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Mon, 9 Jul 2018 13:58:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20NetCommonsTime=E3=81=ABDateTime?= =?UTF-8?q?=E5=9E=8B=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=20https://github.com/NetCommons3/NetCommons3/issues/1284?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/NetCommonsTime.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Utility/NetCommonsTime.php b/Utility/NetCommonsTime.php index db33f3db..7e28a211 100644 --- a/Utility/NetCommonsTime.php +++ b/Utility/NetCommonsTime.php @@ -174,4 +174,20 @@ public function getUserTimezone() { } return $userTimezone; } + +/** + * DateTime型チェック + * + * @param string $value datetimeの値 + * @return bool DateTime型 + */ + public function isDatetime($value) { + try { + // DateTime値チェック($value=20150716150000 or 2018-06-26 11:37:39いずれにも対応) + new DateTime($value, new DateTimeZone('UTC')); + } catch (Exception $e) { + return false; + } + return true; + } }