A user adds an income or expense. If he classifies it as a recurring transaction, he picks from a frequency_dropdown containing (weekly, fortnightly, monthly, etc.). The user also inputs the start date and end date.
I want to make an increment to date as per the frequency selected. For example, if I have weekly then I want to add +1 week using the 'modify' function but this function is not making any modification to the date and is stuck in a continuous if loop.
My first query is successful and inserts the data in the database but the query inside the loop is not working since the date is not increased as per frequency selected.
//db query is done here.
$sde=$_POST['startdateexpense'];
$ede=$_POST['enddateexpense'];
$dt = new DateTime(str_replace("-", "/", $sde));
$dtUntil = new DateTime(str_replace("-", "/", $ede ? $ede : date("m-d-Y")));
$modifiers=[
"Annually"=>"+1 year",
"Daily"=>"+1 day",
"Weekly"=>"+1 week",
"Fort-nightly"=>"+2 weeks",
"Monthly"=>"+1 month",
"Quarterly"=>"+4 months",
"Semi-Annually"=>"+6 months",
"Annually"=>"+1 year"
];
$modifier=$modifiers[$ExpenseFrequency];
$dt->modify($modifier);
if($dt <= $dtUntil){
$dt->modify($modifier);
//db query is done here.
}
INPUT Expected and actual output
Can anyone please help me solve this?