Your Location is: Home > Php

Calculate next next Monday from a fixed date, when reach next next Monday start calculate next 2 Monday again

From: Rangoon View: 3580 adam 
 php

Question

I need to calculate next 2 weeks Monday from a fixed date, after reach the next 2 weeks Monday, start calculate this next 2 weeks Monday again. Keep loop this step. Is it possible to do it in PHP or Javascript?

    $mainStartDate = 1607270400;
    $timeNow = strtotime("now");

    $tempTwoWeeksLaterMonday = strtotime("second monday", $mainStartDate);
    $twoWeeksLaterMonday = strtotime("second monday", $timeNow);

    if($timeNow < $tempTwoWeeksLaterMonday){
        $startDate = $tempTwoWeeksLaterMonday;
    }else{
        $startDate = $twoWeeksLaterMonday;
    }

this is my currently thinking logic in PHP

Best answer