Is there anyway to get the years between a start year and current year in an array, if possible with Carbon?
So this year the array would be:
[2014,2015,2016]
And next year 2017 will be included:
[2014,2015,2016,2017]
Thanks..
Carbon also allows us to generate dates and times based on a set of parameters. For example, to create a new Carbon instance for a specific date use the Carbon::createFromDate() method, passing in the year, month, day, and timezone, as in the following example.
You can only use the diffInDays() function on a Carbon instance. You can create a new one by parsing the end date you're receiving. $end = Carbon::parse($request->input('end_date'));
Carbon is a package by Brian Nesbit that extends PHP's own DateTime class. It provides some nice functionality to deal with dates in PHP. Specifically things like: Dealing with timezones. Getting current time easily.
Solution:
$years = range(Carbon::now()->year, 2014)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With