0

I'm currently trying to find out if a date is in the format of YYYY-DD-MM.

In PHP, I've got this:

if (preg_match('(\d{4})(-)(\d{2})(-)(\d{2})$', $newDateOfBirth))

However I keep getting the following error:

Warning: preg_match(): Unknown modifier '(' in C:\webserver\webroot\index.php on line 105

Tom Walters
  • 15,366
  • 7
  • 57
  • 74
user1060187
  • 957
  • 5
  • 12
  • 28
  • Off-topic tip, I recommend using [mktime()](http://php.net/manual/en/function.mktime.php) or [checkdate()](http://www.php.net/manual/en/function.checkdate.php) to validate that the dates are valid. @mario you can edit comments instead of re-posting them. – kjetilh Mar 10 '13 at 18:25

1 Answers1

1

You are missing the delimiters:

if (preg_match('~(\d{4})(-)(\d{2})(-)(\d{2})$~', $newDateOfBirth))
SomeoneYouDontKnow
  • 1,289
  • 10
  • 15