MevlütÖzdemir
MevlütÖzdemir

Reputation: 3460

Carbon get years between specified start year and current year

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..

Upvotes: 6

Views: 5978

Answers (1)

MevlütÖzdemir
MevlütÖzdemir

Reputation: 3460

Solution:

$years = range(Carbon::now()->year, 2014)

Upvotes: 19

Related Questions