0

我有数据库中的日期和月份,存储在单独的变量中。但是,如果今天是第 7 号,而我减去一周,则该月将是 0 相同的情况。我想添加lo_datelockin_period_date和减去 3 个月,因为我希望它提前 3 个月向我发送电子邮件。如何将数据库中的值设置为我想要的日期?请帮忙。

<?php
include"connect_mysql.php";
$reminder_dates = mysql_query("SELECT*FROM registration_form");
while($row = mysql_fetch_array($reminder_dates)){
$main_dob_day = $row['main_dob_day'];
$main_dob_month = $row['main_dob_month'];   
$main_dob_year = $row['main_dob_year'];

$joint_dob_day = $row['joint_dob_day'];
$joint_dob_month = $row['joint_dob_month'];
$joint_dob_year = $row['joint_dob_year'];

$loan_lo_day = $row['loan_lo_day'];
$loan_lo_month = $row['loan_lo_month'];
$loan_lo_year = $row['loan_lo_year'];

$lockin_period_day = $row['lockin_period_day'];
$lockin_period_month = $row['lockin_period_month'];
$lockin_period_year = $row['lockin_period_year'];

$legal_fee_clawback_day = $row['legal_fee_clawback_day'];
$legal_fee_clawback_month = $row['legal_fee_clawback_month'];
$legal_fee_clawback_year = $row['legal_fee_clawback_year'];     

date_default_timezone_set('UTC');   

$m = date("n"); 
$d = date("j"); 
$y = date("Y");
$time = time();
$today = date('n-j-Y', $time);


//main applicant birthday - reminder 7days in advance
$main_day = $main_dob_day-7;
if($main_day == $d && $main_dob_month == $m){
echo "Mail Sent!";  
}
//

}
?>
4

2 回答 2

2

一个可行的解决方案是:

$main_day = date( 'n-j-Y', strtotime( "today -1 week"));

要将其应用于您的用例:

$time = mktime( 0, 0, 0,  $main_dob_month, $main_dob_day, $main_dob_year);
$main_day = date( 'n-j-Y', strtotime( "-1 week", $time)); echo $main_day;
于 2012-07-10T02:18:07.837 回答
0
$oneWeekAdv=$main_dob_year.'-'.$main_dob_month.'-'.$main_dob_day;
$oneWeekAdv=strtotime(date("y-m-d", strtotime($oneWeekAdv)) . " -1 week");
$oneWeekAdv=date('m-d', $oneWeekAdv);
于 2012-07-10T02:15:22.957 回答