• 구글 계정 로그인

php 날짜 형식 정규식으로 파악해서 내맘데로

페이지 정보

profile_image
작성자 LJM
댓글 0건 조회 324회 작성일 18-12-12 23:08

본문

 

// 날짜가 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]."일"; //일

}

댓글목록

등록된 댓글이 없습니다.