I ha开发者_JS百科ve a string:
$string = "Created on: 06-Sep-08";
I would like to match the date and convert it to 06/09/2008; what is the needed regexp?
Thanks$matches = array();
preg_match('/(\d{2})-(\D*)-(\d{2})/', $string, $matches)
This returns the array matches.
$matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on
http://php.net/manual/en/function.preg-match.php
preg_match('/\:.*/is',...);
And then do a
strtotime(...)
EDIT:
Forgot to add the parantheses
preg_match('/\:(.*)/is',$string,$matches);
精彩评论