Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

noblemfd's avatar

How to validate min date and max date to current year

How to validate min date and max date to current year

I am using Laravel-5.8 for a web application. I have successfully validate minimum date to the current date as shown below:

<div class="col-12 col-sm-4">
   <div class="form-group">
   <label class="control-label"> Start Date:<span style="color:red;">*</span></label>
   <input type="date" class="form-control" placeholder="dd/mm/yyyy" name="start_date"  min="{{Carbon\Carbon::now()->format('Y-m-d')}}">
   </div>
</div>

However, I want to validate the minimum date to the start of the current year and maximum date to the end of the current year.

How do I achieve this?

0 likes
3 replies
noblemfd's avatar

What you have given is specifying the date. I need it to on its own detect the current year, then pick the first day

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102
Carbon::now()->firstOfYear();
Carbon::now()->lastOfYear();

Please or to participate in this conversation.