<?php
$date_str = '1987-08-28';
if(preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/', $date_str, $matchs))
{
echo $matchs[1] . "年" . $matchs[2] . "月" . $matchs[3] . "日";
}
else
{
echo '日期格式不正确';
}
php正则匹配获得年月日方法
作者 iceqi, 02-12 16:57:04
No replies to this topic
#1
发表于 2012/02/12 16:57:04
今天掌握了一个小技巧,用正则匹配获得年月日
目前查看此主题的用户: 1 位
0 位会员, 1 位游客, 0 位隐身会员











