php 날짜 형식 정규식으로 파악해서 내맘데로
페이지 정보
본문
// 날짜가 0000.00.00 형식
if( preg_match("/^([0-9]{4}).([0-9]{1,2}).([0-9]{1,2}).$/", $date) ){
$str = "";
preg_match_all("/^([0-9]{4}).([0-9]{1,2}).([0-9]{1,2}).$/", $date, $matches);
if($matches[2][0] > '3') {
$CNTyear = $RANO['YEAR'];
} else {
$CNTyear = $RANO['YEAR'] +1;
}
$str .= $CNTyear."년";
$str .= sprintf("%02d", $matches[2][0])."월"; //월
$str .= sprintf("%02d", $matches[3][0])."일"; //일
}
// 날짜가 00.00.00 형식
if( preg_match("/^([0-9]{2}).([0-9]{1,2}).([0-9]{1,2}).$/", $date) ){
$str = "";
preg_match_all("/^([0-9]{2}).([0-9]{1,2}).([0-9]{1,2}).$/", $date, $matches);
if($matches[2][0] > '3') {
$CNTyear = $RANO['YEAR'];
} else {
$CNTyear = $RANO['YEAR'] +1;
}
$str .= $CNTyear."년";
$str .= sprintf("%02d", $matches[2][0])."월"; //월
$str .= sprintf("%02d", $matches[3][0])."일"; //일
}
// 날짜가 00.00 형식
if( preg_match("/^([0-9]{1,2}).([0-9]{1,2}).$/", $date) ){
$str = "";
preg_match_all("/^([0-9]{1,2}).([0-9]{1,2}).$/", $date, $matches);
if($matches[1][0] > '3') {
$CNTyear = $RANO['YEAR'];
} else {
$CNTyear = $RANO['YEAR'] +1;
}
$str .= $CNTyear."년";
$str .= sprintf("%02d", $matches[1][0])."월"; //월
$str .= sprintf("%02d", $matches[2][0])."일"; //일
}
// 날짜가 0000.00.00. 00:00 형식
if( preg_match("/^([0-9]{2,4}).([0-9]{2}).([0-9]{2}).(.+?)$/", $date) ){
$str = "";
preg_match_all("/^([0-9]{2,4}).([0-9]{2}).([0-9]{2}).(.+?)$/", $date, $matches);
if($matches[2][0] > '3') {
$CNTyear = $RANO['YEAR'];
} else {
$CNTyear = $RANO['YEAR'] +1;
}
$str .= $CNTyear."년";
$str .= $matches[2][0]."월"; //월
$str .= $matches[3][0]."일"; //일
}
// 날짜가 00.00. 00:00 형식
if( preg_match("/^([0-9]{2}).([0-9]{2}).(.+?):(.+?)$/", $date) ){
$str = "";
preg_match_all("/^([0-9]{2}).([0-9]{2}).(.+?)$/", $date, $matches);
if($matches[1][0] > '3') {
$CNTyear = $RANO['YEAR'];
} else {
$CNTyear = $RANO['YEAR'] +1;
}
$str .= $CNTyear."년";
$str .= $matches[1][0]."월"; //월
$str .= $matches[2][0]."일"; //일
}
- 다음글php URL 파싱 18.10.17
댓글목록
등록된 댓글이 없습니다.