回答編集履歴

1

調整

2021/01/16 07:18

投稿

yambejp
yambejp

スコア116661

test CHANGED
@@ -8,11 +8,15 @@
8
8
 
9
9
  function checkDatetimeFormat($datetime){
10
10
 
11
- $pattern='/^(?P<year>\d+)\-(?P<month>\d+)-(?P<day>\d+) ((?:[01]|)\d|2[0-3]):((?:[0-5]|)\d):((?:[0-5]|)\d$)/';
11
+ $pattern='/^(?P<year>\d+)\-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)$/';
12
+
13
+ preg_match($pattern, $datetime, $m);
12
14
 
13
15
  return preg_match($pattern, $datetime, $m) and
14
16
 
15
- checkdate($m['month'] , $m['day'] , $m['year']);
17
+ checkdate($m['month'] , $m['day'] , $m['year']) and
18
+
19
+ $m['hour']<24 and $m['minute']<60 and $m['second']<60 ;
16
20
 
17
21
  }
18
22