Try this.
$date="2012-09-12";
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$date)) {
return true;
} else {
return false;
}
More Related Contents:
- PHP validation/regex for URL
- PHP regular expressions: No ending delimiter ‘^’ found in
- Replace URLs in text with HTML links
- Remove non-utf8 characters from string
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- How exactly do Regular Expression word boundaries work in PHP?
- Regexp to add attribute in any xml tags
- PHP remove special character from string
- preg_replace: add number after backreference
- Retrieve all hashtags from a tweet in a PHP function
- PHP – regex to allow letters and numbers only
- preg_match() Unknown modifier ‘[‘ help
- Can someone explain the /e regex modifier? [duplicate]
- How do I replace double quotes with single quotes
- How to “Validate” Human Names in CakePHP?
- In PHP, how do I extract multiple e-mail addresses from a block of text and put them into an array?
- How to remove diacritics from text?
- PHP regular expression to match lines starting with a special character
- Using regex to filter attributes in xpath with php
- Unknown modifier ‘/’ in …? what is it? [duplicate]
- PHP – Add link to a URL in a string
- Get last whole number in a string
- How to display a date as iso 8601 format with PHP
- Issue with Laravel Rules & Regex (OR) operator
- RegExp in preg_match function returning browser error
- Regex for password PHP [duplicate]
- regular expression and forward slash
- How to remove all numbers from string?
- Regular expression preg_quote symbols are not detected
- Detecting a url using preg_match? without http:// in the string