Regular Expression Validation Example in PHP

While validating a field we have to use regular expressions and I have explained how to validate html input field with regular expression via PHP.




Format a PHP date for a given format

You will need some formatting for php date strings when you echo them or populating to db and other functions as well. You can first convert that accurate string to DateTime field in php and then format can be applied. Check below example.