'is there any way to keep the month same?
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.
so I can put the min="some date" in input of date
Solution 1:[1]
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);
Solution 2:[2]
Use Carbon::now()->month; to get current month and make conditon according to your query.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Guido Faecke |
| Solution 2 | Sarfaraz khan |
