2022-05-13 12:10:57 날짜 데이터 형식에 12일 1달 3달 6달 더하려면 어떻게 해야할까요??
본문
$sumpoint=(int)$member[mb_point]-(int)$_POST[point];
if((int)$_POST[point]=="9800"){
$timestamp = strtotime($_POST[enddate],"+12 days");
$timestamp2=date("Y-m-d H:i:s", $timestamp);
$enddate=$_POST[enddate]+$timestamp2;
}else if((int)$_POST[point]=="19800"){
$timestamp = strtotime($_POST[enddate],"+1 months");
$timestamp2=date("Y-m-d H:i:s", $timestamp);
$enddate=$_POST[enddate]+$timestamp2;
}else if((int)$_POST[point]=="45800"){
$timestamp = strtotime($_POST[enddate],"+3 months");
$timestamp2=date("Y-m-d H:i:s", $timestamp);
$enddate=$_POST[enddate]+$timestamp2;
}else if((int)$_POST[point]=="79800"){
$timestamp = strtotime($_POST[enddate],"+6 months");
$timestamp2=date("Y-m-d H:i:s", $timestamp);
$enddate=$timestamp2;
}else{
}
if($_POST[point] <= $member[mb_point]){
echo $sql = " update $g5[member_table] set mb_point='$sumpoint', mb_7='$_POST[startdate]', mb_8='$enddate' where mb_id='$member[mb_id]'";
//exit;
$row = sql_query($sql);
mysql_error();
//die( "mysql connect error : " . mysql_error() );
//exit;
}else{
alert("포인트를 충전하세요");
}
날짜 함수값이 더해지지가 않는데요 고수님들 어떻게 하셨나요 도움 부탁드립니다.
답변 1
$timestamp = strtotime($_POST[enddate],"+12 days");
$timestamp2=date("Y-m-d H:i:s", $timestamp);
$enddate=$_POST[enddate]+$timestamp2;
를
$timestamp = strtotime("+12 days", strtotime($_POST['enddate']));
$enddate = date("Y-m-d H:i:s", $timestamp);
이런식으로 바꿔보세요.
($_POST[enddate] -> $_POST['enddate'] 따옴표 필수)