How to cite when true publication date differs from journal's claimed year?
With the advent of "online first" and "just accepted" publication streams, this dilemma is becoming even more common.  It is now frequently the case that a publication will become available and begin gathering citations well before its "official" publication date.

As noted in the answer by Wrzlprmft and Jim Oldfield, publication dates serve two purposes:


Extra meta-data to help with a search for the reference
Establishing priority between competing researchers


The citation that you write only needs to do the first.  Thus, my practice when dealing with multiple publication dates is to write whichever is the "most persistent".  For example, I have had citations like "published online June 2012" doi:XXX", then in another later work cited the same paper as something like "34(4), pp 1-10, January 2013, doi:XXX" once it's progressed in the publication queue to actually receive a final volume/issue/date.

Regarding the question of priority: that's not really your job in a mere citation.  If order of precedence is actually important to your discussion, you should be discussing it in the text, and not just leaving it to the reader to infer from citation dates, because the real story is often more complicated.  That's why in the actual text of many publications, you will see multiple dates in addition to the final publication date.  In the most extreme cases, you will see a long string like: "Submitted Date1, Revised Date2, Accepted Date 3, Published Online Date 4."

In short: don't sweat the precedence issue.  In the citation, use the date that will be most useful in obtaining the full publication, and let precedence questions be handled separately.