Home > Blockchain >  is there any way to keep the month same?
is there any way to keep the month same?

Time:04-30

I have a condition in laravel where I have to put a min date on html input type date but the condition is complex. Condition : 1 : User should only be able to select date from past ten days. 2 : Only two days from previous month. Example lets today date is 4 april then the user should only be able to select from 4 april to down 1 april and 2 days previous month.

CodePudding user response:

You didn't specify how you actually set the date, but here is a PHP version that should get you closer. All you need to do is extract the parts you need from $minDate.

$lastTwo = new DateTime(date('Y-m-d', strtotime(date('Y-m-1') . ' -2 days')));
$lastTen = new DateTime(date('Y-m-d', strtotime('-10 days')));

$minDate = max($lastTen, $lastTwo);

CodePudding user response:

Use Carbon::now()->month; to get current month and make conditon according to your query.

  • Related