How do I fix a deprecation error for DateTime::year? I am trying to work through deprecation warning. I have not touched Craft in a few months, so I am a bit rusty. 

The Deprecation Message is:


  DateTime::year is deprecated. Use the |date('Y') filter instead.


The offending line is:


  {% for year in now.year .. firstEntryEver.postDate.year %}   


Here is the context:

{% set firstEntryEver = craft.entries.section('posts').orderBy('postDate asc').one() %}
{% for year in now.year .. firstEntryEver.postDate.year %}                        
 &lt;a href="/archives/{{ year }}" class="dropdown-item"&gt;
 &lt;i class="material-icons"&gt;date_range&lt;/i&gt; {{ year }}&lt;/a&gt;
 {% endfor %}


So, how do I fix this?
This is how you fix this:

{# Old code #}
{% for year in now.year .. firstEntryEver.postDate.year %}

{# New code #}
{% for year in now.year .. firstEntryEver.postDate |date('Y') %}