我正在从事慢性护理健康项目,在该项目中,我必须确定患者注射的未来日期。医生选择注射的开始日期,然后选择3天(即星期一,星期三,星期五等),这意味着患者每周要来3次。
总注射量为20,每周除以3次。 我面临的问题是,如果医生选择与今天匹配的日期,解析功能将给出错误的结果。 假设今天是星期三,日期是2019-02-06,医生选择了3天:
输出应为: -2019-02-08 -2019-02-11 -2019-02-13
我的控制器代码:
if( $visitstart_date != null)
$startDate = Carbon::parse($visitstart_date);
else $startDate = Carbon::now();
if($perweek_visit1_day != '')
{ //Get date of selected day
$perweek_visit1_dayDate = $startDate->parse($perweek_visit1_day);
}
if($perweek_visit2_day != '')
{ //Get date of selected day
$perweek_visit2_dayDate = $startDate->parse($perweek_visit2_day);
}
if($perweek_visit3_day != '')
{ //Get date of selected day
$perweek_visit3_dayDate = $startDate->parse($perweek_visit3_day);
}
但是当转储3个值时,它会为我提供:
出于测试目的,我还将彼此的下一次访问日期解析为:
if( $visitstart_date != null)
$startDate = Carbon::parse($visitstart_date);
else $startDate = Carbon::now();
if($perweek_visit1_day != '')
{ //Get date of selected day
$perweek_visit1_dayDate = $startDate->parse($perweek_visit1_day);
}
if($perweek_visit2_day != '')
{ //Get date of selected day
$perweek_visit2_dayDate = $perweek_visit1_dayDate ->parse($perweek_visit2_day);
}
if($perweek_visit3_day != '')
{ //Get date of selected day
$perweek_visit3_dayDate = $perweek_visit2_dayDate ->parse($perweek_visit3_day);
}
但它再次为我提供了与以下输出相同的输出: -2019-02-08 -2019-02-11 -2019-02-06
我不知道我要去哪里错,在这方面的任何支持或帮助都将不胜感激。 谢谢,