[英]match date from string php preg_match
我有一個字符串:
$string = "Created on: 06-Sep-08";
我想匹配日期並將其轉換為06/09/2008; 需要什么正則表達式?
謝謝
$matches = array();
preg_match('/(\d{2})-(\D*)-(\d{2})/', $string, $matches)
這將返回數組匹配項。
$ matches [0]將包含與完整模式匹配的文本,$ matches [1]將具有與第一個捕獲的帶括號的子模式匹配的文本,依此類推
preg_match('/\:.*/is',...);
然后做一個
strtotime(...)
編輯:
忘記添加括號
preg_match('/\:(.*)/is',$string,$matches);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.